Confused with .EntireRow.Delete

Gopalakrishnan

Board Regular
Joined
Feb 19, 2013
Messages
110
I'm trying to delete certain rows from the table using 'Clear' button, and the delete part of the code would be something like below:

Code:
    For i = lngUsdRng To 2 Step -1 'lngUsdRng - is the last row used in my table
        Rows(i).EntireRow.Delete
    Next

This code deletes the rows as expected, but when I'm taking the used row count for next iteration it still return the previous range. i.e., if the last run had 23 rows in my table, after deleting the rows also it returns 23 unexpectedly.

I thought that deleting entire row would remove the formats too, so that next time when I take used range count for row, it would return the current value. But it's not as I thought, so please check and help me in understanding this mysterious STOP. Thanks!

~~ Gopi
 
When I do next iteration, I need to start updating the results from certain rows.

Would delete a few rows based on some conditions, and then go with next iterations!
 
Upvote 0
Can you explain what you are actually doing and post the full code?
 
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