Wardylewis
New Member
- Joined
- Jun 7, 2016
- Messages
- 37
Good Morning All,
I am new to the world of userform's and think they are pretty dam amazing. I am currently struggling with a small piece of code and was wondering if somebody could guide me.
I have a userform where users need to input results for an employee. The user inputs the employee ID and then it returns their first name and surname from the "Employeelist" sheet.
The user will then insert the test results and it will add the information to a new row in the "results" sheet when the command button is pressed.
Currently, the search function is working but only if I'm on the "Employeelist" sheet once I come off it, it returns blank boxes and no error messages.
The two options I have thought about but need help for both are:
What do you believe is the best way?
My code so far is:
Thank you for any help in advance.
I am new to the world of userform's and think they are pretty dam amazing. I am currently struggling with a small piece of code and was wondering if somebody could guide me.
I have a userform where users need to input results for an employee. The user inputs the employee ID and then it returns their first name and surname from the "Employeelist" sheet.
The user will then insert the test results and it will add the information to a new row in the "results" sheet when the command button is pressed.
Currently, the search function is working but only if I'm on the "Employeelist" sheet once I come off it, it returns blank boxes and no error messages.
The two options I have thought about but need help for both are:
- Have the VBA code to open the sheet the data is on then do the search. Then change back when the user hits the add button.
- Change the code to search the specific sheet and return the results.
What do you believe is the best way?
My code so far is:
Code:
Dim ID As Range Dim IDRow As Long
Dim BV As String, EID As String
EID = Me.TextBox1.Value
Set ID = Worksheets("Employeelist").Range("A:A").Find(What:=EID, LookAt:=xlWhole)
If ID Is Nothing Then
MsgBox "Error, Value Not Found!", vbCritical + vbOKOnly, "ERROR"
TextBox1.Value = ""
Exit Sub
End If
IDRow = ID.Row
TextBox2.Text = Cells(IDRow, 2).Text
TextBox3.Text = Cells(IDRow, 3).Text
Thank you for any help in advance.
Last edited: