ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   insert formula (https://www.excelbanter.com/excel-programming/407929-insert-formula.html)

ranswert

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

Dim lcell As String
Dim rng as range
lcell = Sheets("Estimates").Range("estdbcboxlnkcell").Offs et(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

Dave Peterson

insert formula
 
..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)



ranswert wrote:

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

Dim lcell As String
Dim rng as range
lcell = Sheets("Estimates").Range("estdbcboxlnkcell").Offs et(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


--

Dave Peterson

ranswert

insert formula
 
Worked great
Thanks You

"Dave Peterson" wrote:

..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)



ranswert wrote:

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

Dim lcell As String
Dim rng as range
lcell = Sheets("Estimates").Range("estdbcboxlnkcell").Offs et(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


--

Dave Peterson



All times are GMT +1. The time now is 07:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com