View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vacuum Sealed Vacuum Sealed is offline
external usenet poster
 
Posts: 259
Default UDF not working for VLookup

On 3/07/2012 12:21 AM, Madiya wrote:
I am trying to write a UDF but it does not work.
Here is my simple code, what am I doing wrong?

===================
Public Function PP(rng)
Dim WB As Workbook

Set WB = Workbooks("Code Master.xls")
MsgBox WB.Sheets(1).Range("A10").Value
Set VLRNG = WB.Sheets("SHEET1").Range("B:K")
'PP = Application.WorksheetFunction.VLookup(rng.Value, VLRNG, 4, 0)
'<<<not working
PP = Evaluate(Application.WorksheetFunction.VLookup(rng , VLRNG, 4,
0))'<<<not working

End Function
==================

Pl help.

Regards,


hi

Try

PP = Evaluate("=VLookup(rng, VLRNG, 4, 0)")

HTH
Mick.