Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Worksheet functions in VBA

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)


"Builder" wrote in message
news:%pxVh.8457$vD4.7422@bigfe9...
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





  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Worksheet functions in VBA

Chip Pearson wrote:
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.









"Builder" wrote in message
news:%pxVh.8457$vD4.7422@bigfe9...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet Functions Steve Peel Excel Worksheet Functions 12 August 25th 08 05:06 AM
Public Functions As Worksheet Available Functions Steve King Excel Programming 3 February 12th 05 07:55 PM
worksheet functions Gmet[_2_] Excel Programming 1 September 3rd 04 04:07 PM
help with worksheet functions ksnapp[_40_] Excel Programming 3 April 5th 04 10:48 PM
VBA Functions for use in Worksheet ZootRot Excel Programming 3 October 10th 03 10:29 AM


All times are GMT +1. The time now is 07:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"