OzGrid

How to delete empty rows with counter

< Back to Search results

 Category: [Excel]  Demo Available 

How to delete empty rows with counter

 

Requirement:

 

The user wants to delete empty rows in a worksheet and display the number of rows deleted by using a counter. But the counter number is not accurate.


The user is looking for  a code line which shows looping from top to bottom, and,
a code line which shows looping from bottom to top.

 

https://www.ozgrid.com/forum/forum/help-forums/excel-vba-macros/148577-deleting-empty-rows-with-counter

 

Solution:

 

While deleting the rows you need to loop in reverse order i.e. from bottom to top.
Lets assume you have 100 rows of data starting from Row1 then you should try the loop like below...

Code:
For i = 100 To 1 Step -1

You can replace the 100 with a variable say LR which finds the last row with data on the sheet.

 

Obtained from the OzGrid Help Forum.

Solution provided by sktneer.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

How to Delete/Hide every nth row
How to disable edit/delete comments
How to create, apply or delete a custom view
How to delete row if Date/Time between 05:00 - 20:00

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.

 

 


Gallery



stars (0 Reviews)