PC Review


Reply
Thread Tools Rate Thread

cell ref in a formula

 
 
miek
Guest
Posts: n/a
 
      23rd Apr 2008
I have the following formula that works
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-7], R2C10:R683C11, 2, FALSE)"

but I would like to use dymanic varaibles. However the below does not work
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-7], $J$&"varX":$K$ & "varY", 2, FALSE)"

could someone help with the syntax
Thanks
 
Reply With Quote
 
 
 
 
James Snell
Guest
Posts: n/a
 
      23rd Apr 2008
There's a couple of errors there:
- first you're setting FormulaR1C1 but not providing an R1C1 format formula
(you're actually using a mix of R1C1 & A1 content. it would probably work but
it could cause you problems later.
- secondly your string handling is broken. I'd be suprised if the VBA
editor let you use it at all.

Here's the code you meant to write...

ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-7], R10C" & VarX & ":R113C" & VarY &
", 2, FALSE)"


"miek" wrote:

> I have the following formula that works
> ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-7], R2C10:R683C11, 2, FALSE)"
>
> but I would like to use dymanic varaibles. However the below does not work
> ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-7], $J$&"varX":$K$ & "varY", 2, FALSE)"
>
> could someone help with the syntax
> Thanks

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subtract cell formula from existing cell formula transferxxx@gmail.com Microsoft Excel Programming 2 12th Dec 2006 12:03 PM
How to place a cell formula after the formula result in the cell? Dmitriy Kopnichev Microsoft Excel Worksheet Functions 8 28th Nov 2003 12:22 PM
How to place a cell formula after the formula result in the cell? Dmitriy Kopnichev Microsoft Excel Discussion 10 28th Nov 2003 12:22 PM
Question: Cell formula or macro to write result of one cell to another cell Frederik Romanov Microsoft Excel Misc 1 8th Jul 2003 03:03 PM
Question: Cell formula or macro to write result of one cell to another cell Frederik Romanov Microsoft Excel Programming 1 8th Jul 2003 03:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:54 AM.