Worksheet functions in VBA

C

Chip Pearson

Use

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



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting LLC
www.cpearson.com
(email on the web site)
 
B

Builder

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
 
B

Builder

Chip said:
Use

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


Thanks Chip,

That threw another error "Method Range of the worksheet class .. failed"

But I figured it out: nameShort =
Application.WorksheetFunction.VLookup(nameLong,
Worksheets("shortNames").Range("A1:B100"), 2)


Thanks for the prompt reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top