ActiveCell.Formula

  • Thread starter Thread starter Matt P.
  • Start date Start date
M

Matt P.

Hello,

Does anyone know how to (inVBA) create

Range("B5").Select
ActiveCell.FormulaR1C1 = "=Test1!R[-3]C[2]"
Range("A4").Select

Where Test1 can be a variable.

I want to be able to enter formulas in cells but I want to
be able to use variables in the formulas. I do not want
to use UDF's so that the user can see the actual formula
used to obtain the result when that particular cell is
active. Thank you.
 
s1 = "Test1"

Range("B5").Select
ActiveCell.FormulaR1C1 = "=" & S1 & "!R[-3]C[2]"
Range("A4").Select

or
s1 = "Test1"
r1 = -3
c1 = 2

Range("B5").Select
ActiveCell.FormulaR1C1 = "=" & S1 & "!R[" & r1 & "]C[" & c1 & "]"
Range("A4").Select


demo'd from the immediate window:
s1 = "Test1"
r1 = -3
c1 = 2
? "=" & S1 & "!R[" & r1 & "]C[" & c1 & "]"
=Test1!R[-3]C[2]
 
Thanks again Tom.
-----Original Message-----
s1 = "Test1"

Range("B5").Select
ActiveCell.FormulaR1C1 = "=" & S1 & "!R[-3]C[2]"
Range("A4").Select

or
s1 = "Test1"
r1 = -3
c1 = 2

Range("B5").Select
ActiveCell.FormulaR1C1 = "=" & S1 & "!R[" & r1 & "]C[" & c1 & "]"
Range("A4").Select


demo'd from the immediate window:
s1 = "Test1"
r1 = -3
c1 = 2
? "=" & S1 & "!R[" & r1 & "]C[" & c1 & "]"
=Test1!R[-3]C[2]


--
Regards,
Tom Ogilvy


Hello,

Does anyone know how to (inVBA) create

Range("B5").Select
ActiveCell.FormulaR1C1 = "=Test1!R[-3]C[2]"
Range("A4").Select

Where Test1 can be a variable.

I want to be able to enter formulas in cells but I want to
be able to use variables in the formulas. I do not want
to use UDF's so that the user can see the actual formula
used to obtain the result when that particular cell is
active. Thank you.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top