FormulaR1C1 using variables

  • Follow


I want to do this but can't:

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

What are my options?
0
Reply Utf 4/21/2010 8:52:01 PM

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
<Cheah@discussions.microsoft.com> wrote:

>I want to do this but can't:
>
>ActiveCell.FormulaR1C1 = "=MyFunction(R[variable]C[variable])"
>
>What are my options?
0
Reply Chip 4/21/2010 9:27:21 PM

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?
0
Reply Utf 4/21/2010 9:51:02 PM

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
0
Reply Dave 4/21/2010 11:24:26 PM

3 Replies
2755 Views

(page loaded in 0.002 seconds)


Reply: