Selelcionar en un Texbox, para poderlo modificar

Cuando en el List Box seleecciono una dato, quiero moverlos a un Texbox para poder hacer los cambio, dejo mi ejemplo para que me puedas ayudar a modificar este paso. Dejo código:

Private Sub CommandButton1_Click()
If Me.Lista.ListIndex < 0 Then
        MsgBox "No se ha elegido ningún registro", vbExclamation, "EXCELeINFO"
    Else
        Modificar.Show
    End If
End Sub
Private Sub Fecha_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Select Case Len(Fecha.Value)
'len = largo o longit
Case 2
'si el textbox tiene 2 caracteres
Fecha.Value = Fecha.Value & "/"
'se colocará automáticamente una "/" luego del segundo caracter
Case 5
'si el textbox tiene 5 caracteres
Fecha.Value = Fecha.Value & "/"
'se colocará automáticamente una "/" luego del quinto caracter
End Select
End Sub
Private Sub Lista_Click()
Range("b5").Activate
    Cuenta = Me.Lista.ListCount
    For i = 0 To Cuenta - 1
        If Me.Lista.Selected(i) Then
            'MsgBox Me.ListBox1.List(i)
            Valor = Me.Lista.List(i)
            Sheets("Inventario").Range("b5:b23").Find(What:=Valor, LookAt:=xlWhole, After:=ActiveCell).Activate
        End If
    Next i
End Sub

1 respuesta

Respuesta
1

Ya recibí el libro. Ni bien lo tenga resuelto dejaré aquí el código.

Las instrucciones para el botón Modificar:

Private Sub CommandButton1_Click()
If Me.Lista.ListIndex < 0 Then
        MsgBox "No se ha elegido ningún registro", vbExclamation, "EXCELeINFO"
    Else
        'x Elsamatilde
        'pasa los datos al 2do UF para modificarlos
        Modificar.TxtFac.Value = Lista.List(Lista.ListIndex, 0)
        Modificar.TxtCan.Value = Lista.List(Lista.ListIndex, 1)
        Modificar.TxtImporte.Value = Lista.List(Lista.ListIndex, 2)
        Modificar.Fecha.Value = CDbl(Lista.List(Lista.ListIndex, 3))
        'guarda la fila del registro a modificar - variable pública
        filx = Lista.ListIndex + 5
        Modificar.TxtFac.SetFocus
        Modificar.Show
    End If
End Sub

La variable 'filx' la declaré como pública en un módulo porque la necesitas para guardar los datos como verás en el botón ACEPTAR del uf Modificar.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas