Como Hacer un formulario para ingresar datos a una base de datos en excel VBA

Dim ultfil As Long
Dim ultimafila As Long
On Error GoTo Errorx
Sheets("PlanDeMonitoreo").Activate
ultfil = Hoja1.Cells.Find("A", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
If Me.TextBox1 = "" Or Me.TextBox2 = "" Or Me.ComboBox1 = "" Or Me.ComboBox2 = "" Or Me.TextBox5 = "" Or Me.TextBox7 = "" Or Me.TextBox8 = "" Or Me.TextBox9 = "" Or Me.TextBox10 = "" Or Me.TextBox11 = "" Or Me.TextBox12 = "" Or Me.TextBox12 = "" Or Me.TextBox13 = "" Or Me.TextBox14 = "" Or Me.TextBox15 = "" Then
MsgBox " Faltan Campos Por completar", vbCritical, "ATENCION !"
ElseIf Application.WorksheetFunction.CountIf(Hoja1.Range("A6:A" & ultfil), Me.TextBox1) >= 1 Then
MsgBox " Este codigo ya esta registrado ", vbCritical, "ATENCION !"
Ingresar.Hide
Unload Me
Load Ingresar
Ingresar.Show
Exit Sub
Range("a6").Select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell = TextBox1.Value
ActiveCell.Offset(0, 1).Select
Else
ultimafila = Range("A" & Rows.Count).End(xlUp).Row + 1
Range("A" & ultimafila).Value = Me.TextBox1
Range("A" & ultimafila).Interior.Color = RGB(153, 204, 255)
Range("B" & ultimafila).Value = Me.TextBox2
Range("C" & ultimafila).Value = Me.ComboBox1
Range("D" & ultimafila).Value = Me.ComboBox2
Range("E" & ultimafila).Value = Me.TextBox5
Range("G" & ultimafila).Value = Me.TextBox7
Range("H" & ultimafila).Value = Me.TextBox8
Range("I" & ultimafila).Value = Me.TextBox9
Range("J" & ultimafila).Value = Me.TextBox10
Range("K" & ultimafila).Value = Me.TextBox11
Range("L" & ultimafila).Value = Me.TextBox12
Range("M" & ultimafila).Value = Me.TextBox13
Range("N" & ultimafila).Value = Me.TextBox14
Range("O" & ultimafila).Value = Me.TextBox15
Cells(Rows.Count, "f").End(xlUp).Offset(1) = ComboBox3
MsgBox " Se añadio registro satisfactoriamente ", vbInformation, " ATENCION !"
Ingresar.Hide
Unload Me
Load Ingresar
Ingresar.Show
End If
Errorx:
If Err.Number = 91 Then
MsgBox "borre los campos y rellene denuevo"
End If
End Sub
2 Respuestas
Respuesta de Percy Fernando Zevallos Rodríguez.
1
Respuesta de Adriel Ortiz Mangia
1