View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Builder[_2_] Builder[_2_] is offline
external usenet poster
 
Posts: 2
Default Worksheet functions in VBA

Why does this VBA code throw Err 1004: failed to get the Vlookup Property of
blah blah

dim nameLong as String, nameShort as String
nameLong = "Here is a long name"
nameShort = Application.WorksheetFunction.VLookup(nameLong,
RangeAbbreviations, 2)

where RangeAbbreviations is a named range in the workbook.


Also, putting the named range in quotes...

nameShort = Application.WorksheetFunction.VLookup(nameLong,
"RangeAbbreviations", 2)

....also fails

Adding a formula to the sheet itself works perfectly.

Any ideas?

Thanks