Creating a formula which references a dynamic cell location

D

Darren

I have a routine for which variables "t" & "s" have a value.

I would like Visual Basic to be able to enter a formula into the
active cell so that it equals whatever value may be contained in cells
(t,s) of the worksheet.

I tried:

Activecell.FoumulaR1C1 = "=R[t]C"

but it is not working.

Any ideas would be much appreciated.
 
D

Dave Peterson

Try:

activecell.formular1c1 = "=r[" & t & "]c[" & s & "]"
I have a routine for which variables "t" & "s" have a value.

I would like Visual Basic to be able to enter a formula into the
active cell so that it equals whatever value may be contained in cells
(t,s) of the worksheet.

I tried:

Activecell.FoumulaR1C1 = "=R[t]C"

but it is not working.

Any ideas would be much appreciated.
 
R

Ron Rosenfeld

I have a routine for which variables "t" & "s" have a value.

I would like Visual Basic to be able to enter a formula into the
active cell so that it equals whatever value may be contained in cells
(t,s) of the worksheet.

I tried:

Activecell.FoumulaR1C1 = "=R[t]C"

but it is not working.

Any ideas would be much appreciated.


In the future, it will be helpful if you always tell us what you mean when you
write "it is not working". It may not always be obvious to those trying to
help you.

In any event, you probably want one of the following:

ActiveCell.FormulaR1C1 = "=R[" & t & "]C[" & s & "]"

or

ActiveCell.Offset(1, 0).FormulaR1C1 = "=R" & t & "C" & s

depending on whether "t" and "s" are absolute references, or relative to
ActiveCell.
--ron
 
D

Darren

I have a routine for which variables "t" & "s" have a value.
I would like Visual Basic to be able to enter a formula into the
active cell so that it equals whatever value may be contained in cells
(t,s) of the worksheet.
Activecell.FoumulaR1C1 = "=R[t]C"

but it is not working.
Any ideas would be much appreciated.

In the future, it will be helpful if you always tell us what you mean when you
write "it is not working".  It may not always be obvious to those trying to
help you.

In any event, you probably want one of the following:

ActiveCell.FormulaR1C1 = "=R[" & t & "]C[" & s & "]"

or

ActiveCell.Offset(1, 0).FormulaR1C1 = "=R" & t & "C" & s

depending on whether "t" and "s" are absolute references, or relative to
ActiveCell.
--ron


Thanks Gentleman. That did the trick. Sorry for the vagueries - I'll
be more specific next time.
 

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

Top