ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   DELETING BLANK ROWS (https://www.excelbanter.com/excel-programming/308432-deleting-blank-rows.html)

Robert Lowe

DELETING BLANK ROWS
 
Hello,

I there an easy way to delete all rows if a certain colum is blank?
I have 5000 rows and wish to delete all, f colum b is blank.

Thank you




Frank Kabel

DELETING BLANK ROWS
 
Hi
try the following macro:
Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index, 2).Value = "" then
rows(row_index).delete
End If
Next
Application.ScreenUpdating = True
End Sub

also have a look at:
http://www.xldynamic.com/source/xld.Deleting.html

--
Regards
Frank Kabel
Frankfurt, Germany


Robert Lowe wrote:
Hello,

I there an easy way to delete all rows if a certain colum is blank?
I have 5000 rows and wish to delete all, f colum b is blank.

Thank you


Ron de Bruin

DELETING BLANK ROWS
 
Try this Robert

Sub DeleteBlankRows()
On Error Resume Next 'In case there are no blank rows
Columns("B").SpecialCells(xlCellTypeBlanks).Entire Row.Delete
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Robert Lowe" wrote in message .. .
Hello,

I there an easy way to delete all rows if a certain colum is blank?
I have 5000 rows and wish to delete all, f colum b is blank.

Thank you






Robert Lowe

DELETING BLANK ROWS
 
Thank you both, they work great!

Regards
Robert

"Robert Lowe" wrote in message
.. .
Hello,

I there an easy way to delete all rows if a certain colum is blank?
I have 5000 rows and wish to delete all, f colum b is blank.

Thank you







All times are GMT +1. The time now is 09:55 PM.

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