Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default vlookup with variable

Hi Group,

ActiveCell.FormulaR1C1 = "=VLOOKUP(""AMAT"",ClosesStock!C[-1]:C,2,FALSE)"

Above works and is hard coded with ""AMAT"", but I am having a hard time
substituting a variable into the Formula. The Variable is ThisSheet and am
trying to get something like this to work:

ActiveCell.FormulaR1C1 = "=VLOOKUP(" & ThisSheet &
",ClosesStock!C[-1]:C,2,FALSE)"

but it fails for lack of the quote marks, it needs Text.

Thanks,
David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default vlookup with variable

You need 3 double quotes instead of just 1

ActiveCell.FormulaR1C1 = "=VLOOKUP(""" & ThisSheet &
""",ClosesStock!C[-1]:C,2,FALSE)"


"David" wrote:

Hi Group,

ActiveCell.FormulaR1C1 = "=VLOOKUP(""AMAT"",ClosesStock!C[-1]:C,2,FALSE)"

Above works and is hard coded with ""AMAT"", but I am having a hard time
substituting a variable into the Formula. The Variable is ThisSheet and am
trying to get something like this to work:

ActiveCell.FormulaR1C1 = "=VLOOKUP(" & ThisSheet &
",ClosesStock!C[-1]:C,2,FALSE)"

but it fails for lack of the quote marks, it needs Text.

Thanks,
David

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default vlookup with variable

Thanks Joel.

David

"joel" wrote:

You need 3 double quotes instead of just 1

ActiveCell.FormulaR1C1 = "=VLOOKUP(""" & ThisSheet &
""",ClosesStock!C[-1]:C,2,FALSE)"


"David" wrote:

Hi Group,

ActiveCell.FormulaR1C1 = "=VLOOKUP(""AMAT"",ClosesStock!C[-1]:C,2,FALSE)"

Above works and is hard coded with ""AMAT"", but I am having a hard time
substituting a variable into the Formula. The Variable is ThisSheet and am
trying to get something like this to work:

ActiveCell.FormulaR1C1 = "=VLOOKUP(" & ThisSheet &
",ClosesStock!C[-1]:C,2,FALSE)"

but it fails for lack of the quote marks, it needs Text.

Thanks,
David

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
vlookup with a variable Mentos Excel Programming 2 July 17th 08 10:18 AM
Vlookup - Variable look_up value? Stcyrk Excel Discussion (Misc queries) 3 October 5th 07 10:17 PM
VLOOKUP using a range variable Henry Hayden Excel Programming 2 November 15th 05 10:55 PM
vlookup using a variable Tom Ogilvy Excel Programming 1 September 15th 04 11:01 PM
variable vlookup Tom Ogilvy Excel Programming 2 September 8th 03 02:58 PM


All times are GMT +1. The time now is 07:11 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"