ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding Empty Rows (https://www.excelbanter.com/excel-programming/271812-re-finding-empty-rows.html)

Don Guillett[_4_]

Finding Empty Rows
 
work backwards
Sub RowBeGone1()
'When you delete rows, it's a good idea to do it backwards! Deleting rows
'going forwards causes problems because suppose you delete row 2. Now what
'WAS row 3 is now row 2. Your code doesn't account for this. Try:
Application.ScreenUpdating = False
'For i = 5000 To 4 Step -1
For i = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
If Cells(i, 1).Value = "" Then Rows(i).Delete
Next
Application.ScreenUpdating = True
End Sub

--
Don Guillett
SalesAid Software
Granite Shoals, TX

"Kevin G" wrote in message
...
I have a spreadsheet with approx. 25,000 rows in it. Some
of those rows are completely blank. I wrote a FOR/NEXT
loop to find and delete those rows, but it's not working
exactly how I want. Here's what I wrote:

range("a2:a25001").select
dim acell as range
for each acell in selection
if acell = "" then
acell.entirerow.delete
end if
next acell

After running this it seems that it finds a few of the
empty rows, deletes them, and then stops looking.
Am I doing something wrong?? Any help would be appreciated.

Thanks,

Kevin





All times are GMT +1. The time now is 11:32 PM.

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