Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Syntax - set variable to result of Vlookup

What ever is returned by the vlookup. If it will be a string, then use
string, but change the + to &

if they will return numbers, then dim it as double or long depending on
whether it will be decimal number or not.

--
Regards,
Tom Ogilvy


"GettingThere" wrote in message
...
Excellent. I had spent waaay to much time assuming that I had the
myVariable/vlookup part wrong!

One more question if I could - are myVariable1 and myVariable2 declared as

a
strings then, or must they be a variant?

Thanks so much... I do appreciate it!


"Tom Ogilvy" wrote:

MyResult = Evaluate(myVariable1) + Evaluate(myVariable2)

--
Regards,
Tom Ogilvy

"GettingThere" wrote in message
...
I need some syntax help please.trying to set a variable to the result

of
this
vlookup formula:

myVariable = "=IF(ISERROR(VLOOKUP($E2,mySheet!myNamedRange, " &
myVariablePositon & ",FALSE)),0,VLOOKUP($E2,mySheet!myNamedRange," &
myVariablePositon & " ,FALSE))"

I've tried various forms of WorksheetFunction.Vlookup & can't get it.

I
could replace the variable myVariablePosition to a specific column

number,
but it is important to me to return a zero in the event of an error.

Ultimately, I want to do something like:

For i = 2 to lstrow

myVariable1 = "=IF(ISERROR(VLOOKUP($E2,mySheet!myNamedRange, " &
myVariablePositon1 & ",FALSE)),0,VLOOKUP($E2,mySheet!myNamedRange," &
myVariablePositon1 & " ,FALSE))"

myVariable2 = "=IF(ISERROR(VLOOKUP($E2,mySheet!myNamedRange, " &
myVariablePositon2 & ",FALSE)),0,VLOOKUP($E2,mySheet!myNamedRange," &
myVariablePositon2 & " ,FALSE))"

myResult = myVariable1 + myVariable2

cells(i,6) = myResult

Next i

Thanks in advance!






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
syntax for variable adamaagard Excel Programming 2 January 20th 06 12:45 AM
vlookup based on random result returns incorrect result rickat Excel Worksheet Functions 1 December 6th 05 01:16 PM
Syntax for variable search Tom Ogilvy Excel Programming 3 August 6th 03 06:16 PM
Syntax for variable search brym Excel Programming 0 August 6th 03 05:41 PM
Syntax for variable search brym Excel Programming 2 August 6th 03 05:32 PM


All times are GMT +1. The time now is 02:55 AM.

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"