Index match to retrieve based on contains VBA

38 Views Asked by At

I am getting an error 1004 "Unable to get the Match property of the WorkSheet function class. Any ideas?

Sub helper()
Dim k As Long

For k = 20 To 49
If Cells(k, 4).Value Like "*Opportunity*" Then

Cells(k, 5).Value = WorksheetFunction.Index(Range("W20:W49"), WorksheetFunction.Match(Cells(k, 22).Value, Range("D20:D49"), 0))

ElseIf Cells(k, 4) <> "" Then
    Cells(k, 5).FormulaR1C1 = _
    "=IFERROR(IF(RC[-1]>1,VLOOKUP(RC[-1],'Data Extract'!C1:C33,2,FALSE),""""),"""")"
    Else
''
End If

Next k

End Sub
0

There are 0 best solutions below