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.
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

maras

New Member
Joined
Dec 12, 2019
Messages
33
Office Version
  1. 2010
Platform
  1. Windows
I don't know what your formulas look like, but try it.
VBA Code:
Sub Delete2()
    Range("E3:168").SpecialCells(xlCellTypeFormulas, xlTextValues).EntireRow.Delete
End Sub
 

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
1,976
Office Version
  1. 365
Platform
  1. Windows
Hi doesn't work I get message run time 1004 then class not registered
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,492
Office Version
  1. 365
Platform
  1. Windows
One way:
VBA Code:
Sub Delete2()

    Dim r as Long

    Application.ScreenUpdating = False

    For r = 168 to 3 Step -1
        If Cells(r, "E").Value = "" Then Rows(r).Delete
    Next r

    Application.ScreenUpdating =True

End Sub
 
Solution

maras

New Member
Joined
Dec 12, 2019
Messages
33
Office Version
  1. 2010
Platform
  1. Windows

ADVERTISEMENT

Missing Letter "E".My mistake.
VBA Code:
Sub Delete2()
    Range("E3:E168").SpecialCells(xlCellTypeFormulas, xlTextValues).EntireRow.Delete
End Sub
 

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
1,976
Office Version
  1. 365
Platform
  1. Windows
its breaks Joe. I think its breaking from the tp
 

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
1,976
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Hi maras it kind of works now but deletes all the rows even when there is something in it. Column E is pulling in from another sheet so it has formula's but some cells below it also pulls in formula's but cell is empty. Those are the only cells i am trying to delete with row.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,492
Office Version
  1. 365
Platform
  1. Windows
its breaks Joe. I think its breaking from the tp
Yes, I had a typo in there, but I fixed it within a minute or two.
You must have copied it before I fixed. Change that "tp" to "to" and it should work.
 

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
1,976
Office Version
  1. 365
Platform
  1. Windows
One way:
VBA Code:
Sub Delete2()

    Dim r as Long

    Application.ScreenUpdating = False

    For r = 168 to 3 Step -1
        If Cells(r, "E").Value = "" Then Rows(r).Delete
    Next r

    Application.ScreenUpdating =True

End Sub
works thanks
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,492
Office Version
  1. 365
Platform
  1. Windows
You are welcome.
 

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