ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FormulaR1C1 using variables (https://www.excelbanter.com/excel-programming/441904-formular1c1-using-variables.html)

Cheah

FormulaR1C1 using variables
 
I want to do this but can't:

ActiveCell.FormulaR1C1 = "=MyFunction(R[variable]C[variable])"

What are my options?

Chip Pearson

FormulaR1C1 using variables
 

Try something like

ActiveCell.FormulaR1C1 = _
"=MyFunction(R" & CStr(variable) & "C" & CStr(variable) & ")"

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com




On Wed, 21 Apr 2010 13:52:01 -0700, Cheah
wrote:

I want to do this but can't:

ActiveCell.FormulaR1C1 = "=MyFunction(R[variable]C[variable])"

What are my options?


B Lynn B

FormulaR1C1 using variables
 
ActiveCell.FormulaR1C1 = "=MyFunction(R" & varR & "C" & varC & ")"

"Cheah" wrote:

I want to do this but can't:

ActiveCell.FormulaR1C1 = "=MyFunction(R[variable]C[variable])"

What are my options?


Dave Peterson

FormulaR1C1 using variables
 
Don't forget your []'s:

Dim Var1 as long
dim Var2 as long

var1 = 21
var2 = 23
ActiveCell.FormulaR1C1 = "=MyFunction(R[" & var1 & "]C[" & var2 & "])"





Cheah wrote:

I want to do this but can't:

ActiveCell.FormulaR1C1 = "=MyFunction(R[variable]C[variable])"

What are my options?


--

Dave Peterson


All times are GMT +1. The time now is 01:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com