Hi, I am hoping I can get some help. I am completely self taught from books and the good people at Google, so if some of my terminology/code looks 'newbie' like, there's a reason.
I have been writing a vba program in excel for a contract management system. I have a quite detailed userform that populates and then returns (upon searching In Column A for a textbox value) the rest of the textbox/combobox data from the excel list.
It has worked perfectly over the past with few days over multiple tests of example data, now I have completed the program, and using the proper data, it is now returning the seemingly well known 'Unable to get the VLookup Property of the worksheet functionclass'
There are 23 textboxes that the Vlookup is populating, and I am using a named range "Lookup" which I learned from a Youtube clip! Get me!
I have cut the first bit of the sub below if you can help me find the error please. The 'Red' text is the yellow highlight in the debug.
Honestly, it has been working fine all week with example data.
Private Sub TextBox1_AfterUpdate()
Application.ScreenUpdating = False
If WorksheetFunction.CountIf(Sheet2.Range("A:A"), Me.TextBox1.Value) = 0 Then
MsgBox "This is an incorrect contract number"
Me.TextBox1.Value = ""
Exit Sub
End If
With Me
.TextBox2 = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), Sheet2.Range("Lookup"), 2, 0)
.TextBox4 = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), Sheet2.Range("Lookup"), 3, 0)
.TextBox5 = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), Sheet2.Range("Lookup"), 4, 0)
.TextBox6 = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), Sheet2.Range("Lookup"), 5, 0)
Display More
Thank you in advance for your assistance.