Hi,
I want to use the MATCH(lookup_value, lookup_array, [match_type]) function in VBA.
I need the lookup_value to be a variable (dim as long), but I can´t get this to work, see below. It works fine when I use a number as lookup_value, but not a variable.
Sub A()
Dim TESTO As Long
Dim Vendor As Long
Dim ComplaintType As String
For X = 7 To 20
ComplaintType = ThisWorkbook.Sheets("rådatacalle").Cells(X, 6).Value
Select Case ComplaintType
Case Is = "Other"
Vendor = ThisWorkbook.Sheets("rådatacalle").Cells(X, 2).Value
'Vendor this time gets the value 8077, but next round in the loop Vendor will have a different value
TESTO = Application.WorksheetFunction.Match("8077", Sheets("Sammanställning").Range("a1:a90"), 0) 'DOES WORK
TESTO = Application.WorksheetFunction.Match(8077, Sheets("Sammanställning").Range("a1:a90"), 0) 'DOES NOT WORK
TESTO = Application.WorksheetFunction.Match("Vendor", Sheets("Sammanställning").Range("a1:a90"), 0) 'DOES NOT WORK. Vendor is a variable with value 8077.
TESTO = Application.WorksheetFunction.Match(Vendor, Sheets("Sammanställning").Range("a1:a90"), 0) 'DOES NOT WORK. Vendor is a variable with value 8077.
I get run-time-error 1004 "Unable to get the MATCH property of the WorksheetFunction class"
Any idea why I can´t use the variable Vendor as lookup_value in the MATCH function?
Bookmarks