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

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
2,072
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.
 
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
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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.
 
Upvote 0

Forum statistics

Threads
1,213,513
Messages
6,114,064
Members
448,545
Latest member
kj9

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