¿Como modificar dato de una hoja excel, a través de un formulario?

Para Dante Amor

Estimado necesito un poco de ayuda!

Le cuento que quiero editar la información de una hoja por medio de un formulario,

Como aparece en la imagen, se carga en el formulario los datos de la hoja, una vez que se cargan en los txt de "ODC" y "MONTO" poder editarla posteriormente presionar el btn editar, poder guardar el nuevo monto en la hoja!

Y es posible que los datos de monto en los listbox, estén separados por un . Ej: 2300000 = 2.300.000

1 Respuesta

Respuesta
1

Te anexo el código actualizado

Private Sub CommandButton3_Click()
'Por.Dante Amor
    If ListBox2.ListIndex < 0 Then
        MsgBox "Selecciona un registro a editar"
        Exit Sub
    End If
    If txtodc = "" Or txtmontoodc = "" Or Not IsNumeric(txtmontoodc) Then
        MsgBox "Captura el nuevo monto"
        Exit Sub
    End If
    fila = ListBox2.List(ListBox2.ListIndex, 3)
    Set h = Sheets("proyectos_excel")
    h.Cells(fila, "E") = CDbl(txtmontoodc)
'CARGAR ODC A LISTBOX2
    Call CARGARODC
    MsgBox "Monto actualizado"
End Sub
'
Sub CARGARODC()
    'CARGAR ODC A LISTBOX2
    ListBox2.Clear
    txtodc = ""
    txtmontoodc = ""
    wkey = ListBox1.List(ListBox1.ListIndex, 0)
    Set h = Sheets("proyectos_excel")
    Set r = h.Columns("F")
    Set b = r.Find(wkey, lookat:=xlWhole)
    If Not b Is Nothing Then
        celda = b.Address
        Do
            ListBox2.AddItem h.Cells(b.Row, "D")                            'ODC
            ListBox2.List(ListBox2.ListCount - 1, 1) = h.Cells(b.Row, "A")  'Marca
            ListBox2.List(ListBox2.ListCount - 1, 2) = Format(h.Cells(b.Row, "E"), "#,##0.00")  'Monto
            ListBox2. List(ListBox2.ListCount - 1, 3) = b. Row 'almacena el número de fila
            Set b = r.FindNext(b)
        Loop While Not b Is Nothing And b.Address <> celda
    End If
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Dim Cuenta As Integer
    Dim Numero As Integer
    Dim j As Integer
    Dim i As Integer
    '
    Cuenta = Me.ListBox1.ListCount
    '
    'Validamos que haya un elemento seleccionado.
    For j = 0 To Cuenta - 1
        If Me.ListBox1.Selected(j) = True Then
            Numero = Numero + 1
        End If
    Next j
    '
    'La hoja seleccionada se pasará al ListBox de hojas visibles.
    For i = 0 To Cuenta - 1
        If Me.ListBox1.Selected(i) = True Then
            'MsgBox Me.ListBox1.List(i, 1), vbInformation, "EXCELeINFO"
            txtproyecto.Text = Me.ListBox1.List(i, 1)
            txtmarca.Text = Me.ListBox1.List(i, 2)
            txttotalproyecto.Text = Me.ListBox1.List(i, 3)
            Hoja1.Range("J1").Value = Me.ListBox1.List(i, 0)
        End If
    Next i
    'CARGAR ODC A LISTBOX2
    Call CARGARODC
End Sub
Private Sub ListBox2_Click()
'Por.Dante Amor
    txtodc = ListBox2.List(ListBox2.ListIndex, 0)
    txtmontoodc = ListBox2.List(ListBox2.ListIndex, 2)
End Sub
'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas