So I'm currently getting an "Expected end of statement" error upon running the provided code. I know that the problem lies in the way that Sub Searched function is written. I'm not really sure where to go from here but you should be able to get a feel for what I need to do from the code provided. Sub Searched works as a standalone just not with the initialize function.
Initialize
Private Sub UserForm_Initialize()
TextBox1.Text = Selection.Value
TextBox2.Text = Searched Sheets("CashHour1").Range("B2:E60"), Selection
End Sub
Command to autofill textbox in initialize function
Sub Searched(Rnge As Range, E_name As String)
On Error Resume Next
Sal = Application.WorksheetFunction.VLookup(E_name, Rnge, 2, False)
Sal1 = Application.WorksheetFunction.VLookup(E_name, Rnge, 3, False)
If Len(E_name) = 0 Then
MsgBox "Select an employee"
ElseIf Len(Sal) < 1 Then
Hours = "OFF"
Else
Hours = Sal & " - " & Sal1
End If
End Sub