ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting formula (https://www.excelbanter.com/excel-programming/379446-re-inserting-formula.html)

Alok

Inserting formula
 
Antonio
I would suggest using FormulaR1C1

..Cells().FormulaR1C1 = "=If(RC17=R37C,RC14,0)"

Alok
"Antonio" wrote:

I need to insert programmatically the following formula in several adjacent
cells

=IF($Q198=R$37,$N198,0)

198 is the row number that varies
R is the column letter that varies

The rest is constant

I cannot copy the cells from above because sometimes I am not supposed to.
Copying the cells from above manually does work.

I am trying:

.Cells(r, 18).Formula = "=IF($Q" & r & "=" & Column() & "$37" & ",$N" & r &
",0)"

where r is the row number
I need to figure out the column()



All times are GMT +1. The time now is 09:31 PM.

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