ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how change formula with this code? (https://www.excelbanter.com/excel-programming/341246-how-change-formula-code.html)

Ian Elliott

how change formula with this code?
 
Thanks for any help.
I have alot of rows of formula to change, and am trying to speed things up
with the below code. But, when I run this, I get apostrophes where I don't
need them. Any idea why?
For i = 19 To 53
Cells(i, 6).FormulaR1C1 = "=VLOOKUP(D" & i &
",Plan_Group_Month,MONTH(Report_Date)+3, FALSE)"
Next i
But this puts (for example, in row 25) the below in, with apostrophes around
the Dxx.
=VLOOKUP('D25',Plan_Group_Month,MONTH(Report_Date) +3, FALSE)

I tried this too, but got an error
Cells(i, 6).FormulaR1C1 = "=VLOOKUP(D" & Str(i) &
",Plan_Group_Month,MONTH(Report_Date)+3, FALSE)"
Thanks for any help

Jim Thomlinson[_4_]

how change formula with this code?
 
You are in R1C1 mode. Change

Cells(i, 6).FormulaR1C1 =
to
Cells(i, 6).Formula =
--
HTH...

Jim Thomlinson


"Ian Elliott" wrote:

Thanks for any help.
I have alot of rows of formula to change, and am trying to speed things up
with the below code. But, when I run this, I get apostrophes where I don't
need them. Any idea why?
For i = 19 To 53
Cells(i, 6).FormulaR1C1 = "=VLOOKUP(D" & i &
",Plan_Group_Month,MONTH(Report_Date)+3, FALSE)"
Next i
But this puts (for example, in row 25) the below in, with apostrophes around
the Dxx.
=VLOOKUP('D25',Plan_Group_Month,MONTH(Report_Date) +3, FALSE)

I tried this too, but got an error
Cells(i, 6).FormulaR1C1 = "=VLOOKUP(D" & Str(i) &
",Plan_Group_Month,MONTH(Report_Date)+3, FALSE)"
Thanks for any help



All times are GMT +1. The time now is 12:20 AM.

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