Macro to delete rows based on blank cells in a column

ariel20029

Board Regular
Joined
Jun 20, 2013
Messages
97
Hi all, I hope you can help. I have a simple code to delete rows based on blank cells in column T. However I believe that the cells are not being seen as Blank due to a prior formula being in the cell and the data being copy paste special to remove formulas. Is there a way to us an IS NULL instead?or is there another option?

Sub DelBlankRows()
Columns("T:T").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Delete
End Sub

<tbody>
</tbody><colgroup><col span="3"></colgroup>
Thank you all for your help :)
Sharon

<tbody>
</tbody><colgroup><col span="3"></colgroup>
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
One option (test on a test sheet obviously as you are deleting rows)

Code:
Sub delrowEmptyStr()
    Dim EmpCol As Range, LstRw As Long
    LstRw = Columns(20).Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
    Set EmpCol = Cells.Find(What:="*", SearchOrder:=xlColumns, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Offset(, 1).EntireColumn
    With Intersect(Rows("2:" & LstRw), EmpCol)
        .FormulaR1C1 = "=IF(RC20="""",""X"","""")"
        .Value = .Value
        .SpecialCells(xlConstants).EntireRow.Delete
    End With
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,604
Messages
6,131,700
Members
449,666
Latest member
Tommy2Tables365

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top