I am using the INDEX + MATCH excel function to look for an specific data on that named range. As my "MATCH" column is the second column (column "B"), I need to use the OFFSET function on that.
An excel example formula is this :
=INDEX(Macro;MATCH($F$29;OFFSET(Macro;0;1;;1);0);MATCH(J$2;Macro!$2:$2;0)))
So, to avoid having that function on all over my spreadsheet, I want to create a function to return such data.
I am trying to create the INDEX + MATCH on VBA and it works, by as soon as a try to use the named range (plus the OFFSET), I get some errors.
This gives me error :
DADOSMACRO = Application.WorksheetFunction.Match(Range("DataIWant"), Range("Macro").Offset(, 1), 0)"
This works :
"DADOSMACRO = Application.WorksheetFunction.Match(Range("DataIWant"), Range("Macro!A8:A37").Offset(, 1), 0)"
Full function:
Public Function DADOSMACRO() As String
DADOSMACRO = Application.WorksheetFunction.Match(Range("$F$29"), _
Range("Macro").Offset(, 1), 0)
End Function
Range("$F$29")
without a specific worksheet will always default to the ActiveSheet, so you may get errors or the wrong result if a different sheet is active. – Tim Williams