Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Divide by variable
Ok, maybe I am not googling correctly (and by no means am I a VBA
guru) but I need help with what seems like a very basic problem.. I am trying to pass a variable into a formula and it is interpreting it as text, not the variable value.. See below for relevent code... DIM VAR1 as integer ActiveCell.FormulaR1C1 = "=(RC[-31]+RC[-27])/VAR1 VAR1 is being incremented in a loop and I have verified it has a value but instead of dividing by 3 for instance it is trying to divide by VAR1. Can someone hold my hand and let me know what rookie mistake I am making??? |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Divide by variable
Ok, maybe I am not googling correctly (and by no means am I a VBA
guru) but I need help with what seems like a very basic problem.. I am trying to pass a variable into a formula and it is interpreting it as text, not the variable value.. See below for relevent code... DIM VAR1 as integer ActiveCell.FormulaR1C1 = "=(RC[-31]+RC[-27])/VAR1 VAR1 is being incremented in a loop and I have verified it has a value but instead of dividing by 3 for instance it is trying to divide by VAR1. You didn't show your closing quote mark, but I am assuming it is at the end of the string of text. That means you are not sending in the contents of VAR1, but rather the text string "VAR1". Once VAR1 is passed that way, there is no way to get to the value it **had** when your macro was running. Try it this way, so that the contents of VAR1 are passed instead. ActiveCell.FormulaR1C1 = "=(RC[-31]+RC[-27])/" & CStr(VAR1) Rick |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Divide by variable
ActiveCell.FormulaR1C1 = "=(RC[-31]+RC[-27])/" & Var1
It's better to copy from the original code and paste into your post. Less chance that typos arise in the posting that don't exist in the real code. wrote: Ok, maybe I am not googling correctly (and by no means am I a VBA guru) but I need help with what seems like a very basic problem.. I am trying to pass a variable into a formula and it is interpreting it as text, not the variable value.. See below for relevent code... DIM VAR1 as integer ActiveCell.FormulaR1C1 = "=(RC[-31]+RC[-27])/VAR1 VAR1 is being incremented in a loop and I have verified it has a value but instead of dividing by 3 for instance it is trying to divide by VAR1. Can someone hold my hand and let me know what rookie mistake I am making??? -- Dave Peterson |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Divide by variable
Just wanted to say thanks to both of you.. Worked like a treat.. I
have one more question for the moment, but that is another post topic ;) Thanks, David |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
variable height variable width stacked bar charts | Charts and Charting in Excel | |||
variable in a link where the variable is the name of the sheet | Excel Worksheet Functions | |||
Sum cells based on a row variable and seperate column variable | Excel Worksheet Functions | |||
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? | Excel Worksheet Functions | |||
Divide one row over other row I dont wont to divide one number | Excel Discussion (Misc queries) |