Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Excel formula error
Hi,
I'm trying to use a variable in a formula and it's not working. Here is the formula: Formula #1 ActiveCell.FormulaR1C1 = "=rc[x]-rc[2]" The value of x is determined in a select case statement. For example depending on the case selection I want the formula to say: Formula #2 ActiveCell.FormulaR1C1 = "rc[-17]-rc[2]" Formula #2 works but Formula #1 doesn't. How can I use a variable in #1 and make it work? Thanks much, -- TomD |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Excel formula error
if x is inside the quotes it is treated as text, not as your variable - do
this instead: ActiveCell.FormulaR1C1 = "=rc[" & x & "]-rc[2]" "TomD" wrote: Hi, I'm trying to use a variable in a formula and it's not working. Here is the formula: Formula #1 ActiveCell.FormulaR1C1 = "=rc[x]-rc[2]" The value of x is determined in a select case statement. For example depending on the case selection I want the formula to say: Formula #2 ActiveCell.FormulaR1C1 = "rc[-17]-rc[2]" Formula #2 works but Formula #1 doesn't. How can I use a variable in #1 and make it work? Thanks much, -- TomD |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error with sum formula in excel 2007 | Excel Worksheet Functions | |||
#NAME? error in formula in 03 but runs okay in excel 07 | Excel Discussion (Misc queries) | |||
Excel Formula Error | Excel Worksheet Functions | |||
Why does Excel say this formula contains an error? | Excel Worksheet Functions | |||
Excel Formula Error | Excel Worksheet Functions |