Faltaría el programar botón guardar

Dante cargan los datos sin ningún problema, pero el botón guardar me faltaría que me guardase los cambios en la misma fila que estaba que me reemplace los cambios anteriores a los actuales.

1 respuesta

Respuesta
1

Listo, te anexo el código

'
Private Sub CommandButton2_Click()
'Por.Dante Amor
    'actualizar datos en la hoja
    If ListBox1.ListIndex = -1 Then
        MsgBox "Debes seleccionar un registro"
        Exit Sub
    End If
    If ComboBox4 = "" Then
        MsgBox "Falta el PTR"
        ComboBox4.SetFocus
        Exit Sub
    End If
    If TextBox2 = "" Then
        MsgBox "Falta el Ubicación"
        TextBox2.SetFocus
        Exit Sub
    End If
    If TextBox3 = "" Then
        MsgBox "Falta el equipo"
        TextBox3.SetFocus
        Exit Sub
    End If
    If TextBox4 = "" Then
        MsgBox "Falta hora termino"
        TextBox4.SetFocus
        Exit Sub
    End If
    '
    'Pasar los datos a la hoja
    fila = Val(ListBox1.List(ListBox1.ListIndex, 8))
    h1.Cells(fila, "B") = Val(ComboBox4)        'ptr
    h1.Cells(fila, "C") = TextBox2              'ubic
    h1.Cells(fila, "D") = TextBox3              'equ
    h1.Cells(fila, "F") = TimeValue(TextBox4)   'hi
    h1.Cells(fila, "G") = TimeValue(TextBox5)   'ht
    h1.Cells(fila, "H") = TextBox1              'desc
    MsgBox "Registro actualizado"
End Sub

sal u dos

Perfecto, el combobox PTR no me carga lo mismo que me carga cuando registro.. solo me faltaría eso.. saludos

El combo ptr es nuevo, tienes que cargarlo al iniciar el userform

Private Sub UserForm_Initialize()
Set h1 = Sheets("Ingresar")
For i = 3 To h1.Range("E" & Rows.Count).End(xlUp).Row
Call Agregar_Fec(ComboBox1, h1.Cells(i, "E").Value)
Call Agregar_Fec(ComboBox2, h1.Cells(i, "E").Value)
Call Agregar(ComboBox3, h1.Cells(i, "A").Value)
Next

ComboBox2.AddItem "800"
ComboBox2.AddItem "805"
ComboBox2.AddItem "806"
ComboBox2.AddItem "807"

End Sub

ASÍ no me carga el combo

Después de esta línea

Call Agregar(ComboBox3, h1.Cells(i, "A").Value)

Pon esta línea

Call Agregar(ComboBox4, h1.Cells(i, "B").Value)

Me salen todos menos el 800

Esto:

ComboBox2. AddItem "800"

No lo programé yo, tendría que revisarlo.

No te carga el 800, porque en la hoja solamente tienes 805,806 y 807.

Si quieres cargar el 800 y otro números que no existan en la hoja, entonces quita la línea

Call Agregar(ComboBox4, h1.Cells(i, "B").Value)

Y después del next pon estas líneas

ComboBox2.AddItem "800"
ComboBox2.AddItem "805"
ComboBox2.AddItem "806"
ComboBox2.AddItem "807"


Private Sub UserForm_Initialize()
    Set h1 = Sheets("Ingresar")
    For i = 3 To h1.Range("E" & Rows.Count).End(xlUp).Row
        Call Agregar_Fec(ComboBox1, h1.Cells(i, "E").Value)
        Call Agregar_Fec(ComboBox2, h1.Cells(i, "E").Value)
        Call Agregar(ComboBox3, h1.Cells(i, "A").Value)
    Next
    ComboBox2. AddItem "800"
    ComboBox2. AddItem "805"
    ComboBox2. AddItem "806"
    ComboBox2. AddItem "807"
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas