Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default cell ref in a formula

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default cell ref in a formula

There's a couple of errors the
- 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
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
How can I make a blank cell in a formula cell with a range of cell Vi Excel Discussion (Misc queries) 5 June 21st 07 02:46 PM
Subtract cell formula from existing cell formula [email protected] Excel Programming 2 December 12th 06 12:03 PM
get the value of a formula in cell B1 into cell A1 without changing my current cell selection News[_4_] Excel Programming 3 October 21st 06 12:24 AM
Cell Formula reference to cell Based On third Cell Content Gabriel Excel Discussion (Misc queries) 0 February 11th 05 05:35 AM
Question: Cell formula or macro to write result of one cell to another cell Frederik Romanov Excel Programming 1 July 8th 03 03:03 PM


All times are GMT +1. The time now is 06:45 PM.

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

About Us

"It's about Microsoft Excel"