Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using variable inside formulaR1C1 for offseting

Tags:

excel

vba

I have the following line of code:

ActiveCell.FormulaR1C1 = "=sqrt(RC[-1])"

Now instead of -1, I want to use a variable, say x, as follows:

ActiveCell.FormulaR1C1 = "=sqrt(RC[x])"

This returns an error. Is there any way I can do this?

like image 434
user2812791 Avatar asked Sep 24 '13 21:09

user2812791


1 Answers

Like this:

ActiveCell.FormulaR1C1 = "=sqrt(RC[" & x & "])"
like image 129
RBarryYoung Avatar answered Oct 19 '22 12:10

RBarryYoung