Hi Everyone,
I'm currently working on a User Form in Excel. I'm almost done with it I just need one last piece of info.
This Userform consists of textboxes
ex:
txtbox1
txtbox2
txtbox3
txtbox4
txtbox5
now, initially you would enter any value on each textbox then there is button on that userform that would past all the information on a sheet name "Database"
now, what I want to happen is to automatically populate values of txtbox 2 to 5 if the value of txtbox1 was recently added to the "database" sheet. If no matches found, then just add the assigned date as the date today like what I have on my code.
This is my code and it is not working...
Private Sub txtTIN_AfterUpdate()
On Error GoTo ErrHandler
If IsNewOrder(txtbox1.Value) = False Then
txtbox2.Text = Worksheets("Database").Cells(OrderRow, 3).Value
txtbox3.Text = Worksheets("Database").Cells(OrderRow, 4).Value
txtbox4.Text = Worksheets("Database").Cells(OrderRow, 5).Value
txtbox5.Text = Worksheets("Database").Cells(OrderRow, 6).Value
Else
txtDate.Text = Format(Now(), "mm/dd/yyyy")
End If
Exit Sub
ErrHandler:
If Err.Number = 13 Then Resume Next
End Sub
Private Function IsNewOrder(SearchKey As String) As Boolean
On Error GoTo ErrCheck
Dim OrderRow As Long
OrderRow = Application.Match(SearchKey, Sheets("Database").Range("B:B"), 0)
If OrderRow = 0 Then IsNewOrder = True
Exit Function
ErrCheck:
If Err.Number = 13 Then
OrderRow = 0
IsNewOrder = True
Resume Next
End If
End Function
Please help... Thank you
Bookmarks