Creating a formula which references a dynamic cell location

  • Thread starter Thread starter Darren
  • Start date Start date
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.
 
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.
 
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
 
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.
 
Back
Top