Update dynamic range in For...Loop?

BigDelGooner

Board Regular
Joined
Aug 17, 2009
Messages
197
Hi guys

I've simplified the code but having trouble with the following...

for c = 3 to Range("A65536").end(xlup).row
if cells(c,2).value = true then
rows(c).insert
end if
next

Basically because I am inserting row during the procedure the loop only remembers the initial last row rather than continually checking the range("A65536").end(xlup).row after each loop.

I have tried using a named range (i.e. End_Row) and incorporating this into the loop but this doesnt work either.

Any ideas?
 
Thjat's because the terminating value of a FOR...NEXT loop is evaluated once at the start whereas the terminating condition of a DO...LOOP is evaluated every loop.

Incidentally you can also modify the value of the control variable in a FOR...NEXT loop if you're careful.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top