Anexo el código, realiza todas tus pruebas para crear nuevas empresas, nuevos productos y modificar productos.
Private Sub cmbInsertar_Click()
'Por.Dante Amor http://www.todoexpertos.com/preguntas/6dfdswlh5iak7bjd/correccion-para-macro-excel-para-insertar-datos-mandando-error
'Obligar a llenar las cajas del 6 al 9
Dim vcs, vtx, i, LastRow, u
Application.ScreenUpdating = False
If CheckBox1 Then
'inserta datos empresa
If TextBox6 = "" Or TextBox7 = "" Or TextBox8 = "" Or TextBox9 = "" Then
MsgBox "Completar los datos", vbExclamation
TextBox6.SetFocus
Exit Sub
End If
'
If Not IsDate(TextBox6) Then
MsgBox "Capturar una fecha válida", vbExclamation
TextBox6.SetFocus
Exit Sub
End If
'
Range("C8") = TextBox6 'Fecha
Range("E8") = TextBox7 'Nombre Empresa
Range("J8") = TextBox8 'Repuestos para
Range("D9") = TextBox9 'Serial Maq/Mot.
Range("G9") = TextBox10 'Marca
Range("K9") = TextBox11 'Modelo/Ident.
'Range("D46").Value = TextBox12.Value 'Notas
Range("D46").Value = Left(TextBox12.Value, 450) 'Notas
Else
'Productos
If CheckBox2 Then
'modifica producto
u = ComboBox1.ListIndex + 11
Else
'inserta producto
u = Range("b" & Rows.Count).End(xlUp).Row + 1
End If
Cells(u, "B") = TextBox1 'Item #
Cells(u, "C") = TextBox2 'Producto #
Cells(u, "D") = TextBox3 'Descripcion del Producto
Cells(u, "J") = Val(TextBox4) 'Cant.
Cells(u, "K") = TextBox5 'Pagina #
End If
'ActiveSheet.Protect Password:="123"
Application.ScreenUpdating = True
TextBox1 = "": TextBox2 = "": TextBox3 = "": TextBox4 = "": TextBox5 = "": TextBox6 = "": _
TextBox7 = "": TextBox8 = "": TextBox9 = "": TextBox10 = "": TextBox11 = "": TextBox12 = ""
ComboBox1 = ""
End Sub
sal u dos