ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting Formula moving down each row (https://www.excelbanter.com/excel-programming/411332-inserting-formula-moving-down-each-row.html)

iashorty

Inserting Formula moving down each row
 
Put formula into col. S as long as same row in col J has something in it.

Range("S2").Select
x = ActiveCell.Row
Do While Cells(x, 10).Value < ""
ActiveCell.FormulaR1C1 = _
"=IF(RC[-9]=""EVT2"",1,IF(RC[-9]=""EVT3"",2,9))"
x = x + 1
Loop

End Sub

Why doesn't this move to the next row?


Nick Hodge[_2_]

Inserting Formula moving down each row
 
You are not moving anything, the activecell is not changing (not that it
needs to)

Range("S2").Select
x = ActiveCell.Row
Do While Cells(x, 10).Value < ""
cells(x,19).FormulaR1C1 = _
"=IF(RC[-9]=""EVT2"",1,IF(RC[-9]=""EVT3"",2,9))"
x = x + 1
Loop

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
web:
www.excelusergroup.org
web: www.nickhodge.co.uk





"iashorty" wrote in message
...
Put formula into col. S as long as same row in col J has something in it.

Range("S2").Select
x = ActiveCell.Row
Do While Cells(x, 10).Value < ""
ActiveCell.FormulaR1C1 = _
"=IF(RC[-9]=""EVT2"",1,IF(RC[-9]=""EVT3"",2,9))"
x = x + 1
Loop

End Sub

Why doesn't this move to the next row?


JP[_4_]

Inserting Formula moving down each row
 
You are only incrementing the cell being checked, not the selected
cell.

Cells(2,10).Value
Cells(3,10).Value
Cells(4,10).Value

etc

HTH,
JP

On May 21, 4:02*pm, iashorty
wrote:
Put formula into col. S as long as same row in col J has something in it.

Range("S2").Select
* * x = ActiveCell.Row
* * Do While Cells(x, 10).Value < ""
* * * * ActiveCell.FormulaR1C1 = _
* * * * * * "=IF(RC[-9]=""EVT2"",1,IF(RC[-9]=""EVT3"",2,9))"
* * * * x = x + 1
* * Loop

End Sub

Why doesn't this move to the next row?




All times are GMT +1. The time now is 08:25 AM.

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