PDA

View Full Version : Solved: Selecting Row with variable



MiguelCSUN
04-19-2010, 01:50 PM
I am trying to update a set of equations based on a new data points.


ActiveCell.FormulaR1C1 = "=ROUND((R[5]C-R[1300]C)/60,1)"

Is there a way to use variables or a named cell to change the rows? What i would like to do is name a cell start and type 5 in it and name a cell finish and type 1300 and run the macro to update the equations as if the equations were written as:

ActiveCell.FormulaR1C1 = "=ROUND((R[start]C-R[finish]C)/60,1)"

p45cal
04-19-2010, 02:09 PM
some examples:
ActiveCell.FormulaR1C1 = "=ROUND((R[" & 5 & "]C-R[" & 1300 & "]C)/60,1)"
ActiveCell.FormulaR1C1 = "=ROUND((R[" & Range("A1").Value & "]C-R[" & range("B1").Value & "]C)/60,1)"
ActiveCell.Formula= "=ROUND((I" & Range("A1").Value & "-$I$" & range("B1").Value & ")/60,1)"

note the last one is
.Formula
not
.FormulaR1C1
which you might find easier to get on with.

MiguelCSUN
04-19-2010, 02:23 PM
Thanks this works great. Do you know if I would be able to use a named cell in place of a specified cell?
Thanks again,
Miguel

MiguelCSUN
04-19-2010, 02:44 PM
Never mind I got it I just replaced the cell name with the label:

ActiveCell.FormulaR1C1 = "=ROUND((R[" & Range("End").Value & "]C-R[" & Range("Start").Value & "]C)/60,1)"

mdmackillop
04-20-2010, 05:29 AM
Hi Miguel,
If your question is Solved, please mark it so using the Thread Tools dropdown.
Regards
MD