insert formula

R

ranswert

I have this code to enter a formula into a cell:

Dim lcell As String
Dim rng as range
lcell = Sheets("Estimates").Range("estdbcboxlnkcell").Offset(estnum,
0).Address
rng.FormulaR1C1 = "=if(" & lcell & ",RC[-2],0)"

I get an error message when it is run. What am I doing wrong?
Thanks
 
D

Dave Peterson

..Address returns the address in A1 reference style. You want to use R1C1
reference style.

lcell = Sheets("Estimates").Range("estdbcboxlnkcell") _
.Offset(estnum, 0).Address(ReferenceStyle:=xlR1C1)


I have this code to enter a formula into a cell:

Dim lcell As String
Dim rng as range
lcell = Sheets("Estimates").Range("estdbcboxlnkcell").Offset(estnum,
0).Address
rng.FormulaR1C1 = "=if(" & lcell & ",RC[-2],0)"

I get an error message when it is run. What am I doing wrong?
Thanks
 
R

ranswert

Worked great
Thanks You

Dave Peterson said:
..Address returns the address in A1 reference style. You want to use R1C1
reference style.

lcell = Sheets("Estimates").Range("estdbcboxlnkcell") _
.Offset(estnum, 0).Address(ReferenceStyle:=xlR1C1)


I have this code to enter a formula into a cell:

Dim lcell As String
Dim rng as range
lcell = Sheets("Estimates").Range("estdbcboxlnkcell").Offset(estnum,
0).Address
rng.FormulaR1C1 = "=if(" & lcell & ",RC[-2],0)"

I get an error message when it is run. What am I doing wrong?
Thanks
 

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