ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to delete blank rows (https://www.excelbanter.com/excel-programming/340208-macro-delete-blank-rows.html)

Barb Reinhardt

Macro to delete blank rows
 
I have the following, but I need it to be more generic.

Sub Macro5()

Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="="
Rows("8:8").Select <---- I want this to be the first
blank row not row 8.
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter Field:=1
End Sub


Thanks in advance,
Barb Reinhardt

Dave Peterson

Macro to delete blank rows
 
There might be quicker ways to do it.

on error resume next
Range("A9:A65536").Cells.SpecialCells(xlCellTypeBl anks).EntireRow.Delete
on error goto 0

Change the range to what you want.

This will only delete really empty cells--not formulas that evaluate to "".

(so there is a difference)

Barb Reinhardt wrote:

I have the following, but I need it to be more generic.

Sub Macro5()

Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="="
Rows("8:8").Select <---- I want this to be the first
blank row not row 8.
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter Field:=1
End Sub

Thanks in advance,
Barb Reinhardt


--

Dave Peterson


All times are GMT +1. The time now is 05:40 PM.

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