UDF not working for VLookup
PPS.... I wrote:
"Madiya" wrote:
[....]
Set WB = Workbooks("Code Master.xls")
MsgBox WB.Sheets(1).Range("A10").Value
Set VLRNG = WB.Sheets("SHEET1").Range("B:K")
[....]
PP = Evaluate(Application.WorksheetFunction.VLookup(rng , VLRNG, 4,
0))'<<<not working
[....]
Ostensibly, the Evaluate syntax should be:
PP = Evaluate("vlookup(" & rng & ",'[Code Master.xls]Sheet1'!B:K,4,0)")
If your purposeful intent is to use a variable reference like VLRNG, the
syntax would be:
PP = Evaluate("vlookup(" & rng & "," & VLRNG.Address(external:=True) &
",4,0)")
The point is: the parameter of Evaluate is a __string__ whose value is a
formula as it would appear in Excel.
|