Delete Row if column E range is empty but has formula inside

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
1,976
Office Version
  1. 365
Platform
  1. Windows
VBA Code:
Sub Delete2()
Range("E3:E168").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub

This works fine if column E is empty, but if there is a formula inside it and even though its blank. It will not delete row. So i think its needs something added if the cells are blank even if a formula is inside it. Still delete the row.
 

maras

New Member
Joined
Dec 12, 2019
Messages
33
Office Version
  1. 2010
Platform
  1. Windows
Try.
VBA Code:
Sub Delete2()
    Dim cel As Range
    
    For Each cel In Range("E3:E168")
        If Cells(cel.Row, "e") = "" Then
            Cells(cel.Row, "e") = ""
        End If
    Next
    Range("E3:E168").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,492
Office Version
  1. 365
Platform
  1. Windows
Try.
VBA Code:
Sub Delete2()
    Dim cel As Range
   
    For Each cel In Range("E3:E168")
        If Cells(cel.Row, "e") = "" Then
            Cells(cel.Row, "e") = ""
        End If
    Next
    Range("E3:E168").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
That is a little bit overkill/unnecessary.

If you are going to loop through each cell in column E anyway, you might as well use the code that I provided which deletes the row right away, as opposed to changing its value, and then deleting it after the fact.

By suppressing the Screen Updates until the end of the code, it will not have that "screen flicker" as it goes through all the rows. It won't update the screen until the macro is complete.
 

Watch MrExcel Video

Forum statistics

Threads
1,126,998
Messages
5,622,097
Members
415,876
Latest member
csibonga2k17

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
Top