Hi - I am trying to input a file number (example = 11-F01234) into a userform and then have corresponding data populate in the other fields of the userform. My userform is not throwing any errors but it also is not returning the values. Can anyone see what I am doing wrong with the below code?
Reg 1 = the textbox where I am putting in the file number. Reg 2 = the lookup values.... on a sidenote - I am then going to use the return values to populate fields on a web page so will need to be able to reference them after
Private Sub Reg1_AfterUpdate()
Dim lr As Long
lr = Range("C" & Rows.Count).End(xlUp).Row
If WorksheetFunction.CountIf(Sheets("FLHearingsMaster").Range("C24:C" & lr), Me.Reg1.Value) = 0 Then
MsgBox "File Number Not Found"
Exit Sub
End If
With Me
.Reg2 = Application.WorksheetFunction.VLookup(Me.Reg1.Text, Sheets("FLHearingsMaster").Range("C24:C" & lr), 3, 0)
.Reg3 = Application.WorksheetFunction.VLookup(Me.Reg1.Text, Sheets("FLHearingsMaster").Range("C24:C" & lr), 3, 0)
.Reg4 = Application.WorksheetFunction.VLookup(Me.Reg1.Text, Sheets("FLHearingsMaster").Range("C24:C" & lr), 4, 0)
.Reg5 = WorksheetFunction.VLookup(Me.Reg1.Text, Sheets("FLHearingsMaster").Range("C24:C" & lr), 5, 0)
.Reg6 = WorksheetFunction.VLookup(Me.Reg1.Text, Sheets("FLHearingsMaster").Range("C24:C" & lr), 6, 0)
.Reg7 = WorksheetFunction.VLookup(Me.Reg1.Text, Sheets("FLHearingsMaster").Range("C24:C" & lr), 20, 0)
.Reg8 = WorksheetFunction.VLookup(Me.Reg1.Text, Sheets("FLHearingsMaster").Range("C24:C" & lr), 21, 0)
End With
End Sub
Bookmarks