I'm trying to run "for loop" certain times and occasionally add an extra row in the range being under the loop. Let's say, that example has originally 15 rows, and during the loop, the condition is true 2 times, so it should add +2 to the total number of rows. However, the code doesn't seem to execute the loop for those added rows and exits right after passing the value of orc=15.
Code below:
sub loop_to_orc()
dim i as integer, orc as integer
dim operations as range
set operations = range(cells(1, 1), cells(, 1).end(xldown))
orc = operations.rows.count
for i = 1 to orc
if cells(i,1)>0 then
rows(i+1).insert
end if
orc = operations.rows.count
next i
end sub
Where am I wrong? Is there any method to actually run the loop for added rows?