ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   delete row if a cell is blank (https://www.excelbanter.com/excel-programming/367900-delete-row-if-cell-blank.html)

Steve Mackay

delete row if a cell is blank
 
Hi All,

I would like to write a basic macro that will search a column and
delete a row if the cell is blank

A
1 Orange
2
3 Apple
4 Pear
5
6 Grape

For instance, I would like the macro to delete rows two and five in the
above example. The number of rows to search will vary, so maybe it
would be easier to start at the bottom of the worksheet and work up.
Also, there may be text in other columns, so the whole row won't
necessarily be blank.

Thanks,
Steve


Steve Mackay

delete row if a cell is blank
 
Nevermind, I think I was able to find the answer from Dave Ritchie.

Thanks!
Steve

Sub EliminateBlankColumnC()
On Error Resume Next ' In case there are no blanks
Columns("C:C").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete
ActiveSheet.UsedRange 'Resets UsedRange for Excel 97
End Sub

Steve Mackay wrote:
Hi All,

I would like to write a basic macro that will search a column and
delete a row if the cell is blank

A
1 Orange
2
3 Apple
4 Pear
5
6 Grape

For instance, I would like the macro to delete rows two and five in the
above example. The number of rows to search will vary, so maybe it
would be easier to start at the bottom of the worksheet and work up.
Also, there may be text in other columns, so the whole row won't
necessarily be blank.

Thanks,
Steve




All times are GMT +1. The time now is 01:31 PM.

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