Hi all,
I've searched the forum for a response on this, but I don't think it's because of vlookup itself - I must be making some kind of basic error I'm not seeing .
Background: I have a form with a textbox, and want to use vlookup each time the value of the textbox changes in order to check whether the value is one that exists on a background worksheet.
Problem: Even though vlookup is shown as a worksheet function available in VBA, I get 'compile error: sub or function not defined'.
Sub txt_AcYear_Change()
Dim AcademicYear As String
AcademicYear = VLookup(txt_AcYear.Text, Worksheets("_background").Range("C:C"), 1, False)
lbl_GetIsValid.Caption = AcYear 'This will show whether the textbox value ' has been found
End Sub
...just to confirm, this is the code attached to the textbox change event.
Can anyone see what I'm doing wrong?
Thanks for reading,
Fray
UPDATE: Also, changing it to
AcademicYear = Application.VLookup(txt_AcYear.Text, Worksheets("_background").Range("C:C"), 1, False)
gives me a type mismatch error instead, in case anyone was going to suggest that.