Te anexo el código para ingresar un registro
Dim h
'
Private Sub ComboBox2_Change()
'Por.Dante Amor
Label10.Caption = ""
If ComboBox2 = "" Or ComboBox2.ListIndex = -1 Then
Exit Sub
End If
f = ComboBox2.ListIndex + 2
Label10.Caption = h.Cells(f, "B")
End Sub
'
Private Sub CommandButton1_Click()
'
' Por Dante Amor
'
If ComboBox1.Value = "" Or ComboBox1.ListIndex = -1 Then
MsgBox "Selecciona un Empresa", vbExclamation, "INGRESAR"
ComboBox1.SetFocus
Exit Sub
End If
If TextBox1.Value = "" Or Not IsDate(TextBox1.Value) Then
MsgBox "Captura una fecha valida", vbExclamation, "INGRESAR"
TextBox1.SetFocus
Exit Sub
End If
If ComboBox2.Value = "" Or ComboBox2.ListIndex = -1 Then
MsgBox "Selecciona un Código", vbExclamation, "INGRESAR"
ComboBox2.SetFocus
Exit Sub
End If
If TextBox4.Value = "" Or Not IsNumeric(TextBox4.Value) Then
MsgBox "Captura una Cantidad valida", vbExclamation, "INGRESAR"
TextBox4.SetFocus
Exit Sub
End If
'
Set h1 = Sheets(ComboBox1.Value)
u = h1.Range("A" & Rows.Count).End(xlUp).Row + 1
h1.Cells(u, "A").Value = CDate(TextBox1.Value) 'fec
h1.Cells(u, "B").Value = ComboBox2.Value 'cod
h1.Cells(u, "C").Value = Label10.Caption 'des
h1.Cells(u, "D").Value = TextBox2.Value 'pro
h1.Cells(u, "E").Value = TextBox3.Value 'rem
h1.Cells(u, "F").Value = Val(TextBox4.Value) 'can
h1.Cells(u, "G").Value = TextBox5.Value 'lot
h1.Cells(u, "H").Value = TextBox6.Value 'obs
MsgBox "Registro ingresado"
Call Limpiar
End Sub
'
Sub Limpiar()
ComboBox1.Value = ""
ComboBox2.Value = ""
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
End Sub
'
Private Sub UserForm_Activate()
Set h = Sheets("Listado")
'carga códigos
For i = 2 To h.Range("A" & Rows.Count).End(xlUp).Row
ComboBox2.AddItem h.Cells(i, "A")
Next
'carga empresas
For i = 2 To h.Range("D" & Rows.Count).End(xlUp).Row
ComboBox1.AddItem h.Cells(i, "D")
Next
End Sub
'
Private Sub CommandButton2_Click()
Unload Me
End Sub
sal u dos