i have currently made a form using excel see below
forms.jpg
i would like to create a code that would use the textbox1 and textbox2 as search criteria
and then for it to insert the data in textbox3,4 and 5 into required cells
for example
textbox 2 to search for the worksheet for requested Vehicle Reg then
textbox 1 to search for the cell with the exact date already inserted then
for the data in textbox3 to be written in B4
for the data in textbox4 to be written in C4
and for the data in textbox5 to be written in E4
in any one sheet per vehicle i have 365 days
and i have a total of about 51 vehicles
any help would be greatly appriciated
the code i have already for the ok button is as below,
Private Sub UserForm_Initialize()
Dim TodaysDate As String
TodaysDate = Format(Now(), "dd/mm/yyyy")
TextBox1.Value = TodaysDate
End Sub
Private Sub cmdOK_Click()
Dim x As Integer
' Check user input
If TextBox2.Text = vbNullString Then
MsgBox "please enter Vehicle Reg.", vbExclamation, "Vehicle Mileage"
TextBox2.SetFocus
Exit Sub
End If
If Not IsNumeric(TextBox3.Value) Then
MsgBox "The Start Mileage Should Be A Figure.", vbExclamation, "Vehicle Mileage"
TextBox3.SetFocus
Exit Sub
End If
If Not IsNumeric(TextBox4.Value) Then
MsgBox "The End Mileage Should Be A Figure.", vbExclamation, "Vehicle Mileage"
TextBox4.SetFocus
Exit Sub
End If
If Not IsNumeric(TextBox5.Value) Then
MsgBox "The Fuel Should Be A Figure.", vbExclamation, "Vehicle Mileage"
TextBox5.SetFocus
Exit Sub
End If
MsgBox "Data Input Complete"
' Clear the form
For x = 2 To 5
Me.Controls("TextBox" & x).Value = ""
Next x
End Sub
again any help would be greatly appriciated
Bookmarks