Deleting Row question

markb9

New Member
Joined
Mar 20, 2009
Messages
8
Hi, I am having a problem with deleting row data in excel. I want the macro to look at columns H and I, starting from row 17 and going down to row 500. I want the macro to delete the entire row if the both the values in H and I for that row are blank or 0.

I'v been trying to edit the following code to work but it does not start from row 17 and moves all the rows in the table up to row 1:

Sub IfBothBlankDeleteRow()
BC1 = UCase("H")
BC2 = UCase("I")
TopRow = 17
BottomRow = 53

Application.ScreenUpdating = False
With Range(BC1 & TopRow & ":" & BC2 & BottomRow)
.AutoFilter
.AutoFilter Field:=1, Criteria1:="="
.AutoFilter Field:=Asc(BC2) - Asc(BC1) + 1, Criteria1:="="
Columns(BC1).SpecialCells(4).EntireRow.Delete
.AutoFilter
End With
Application.ScreenUpdating = True
End Sub

Thanks for the help
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Try replacing:

Columns(BC1).SpecialCells(4).EntireRow.Delete

with:

.SpecialCells(xlCellTypeVisible).EntireRow.Delete
 
Upvote 0
Thats solved the problem for the blank cells, thanks.

Is there a way to edit what i've already done, with your help, to eliminate cells occupied with a 'blank', '0' or '-' ?

Also is there a way to get rid of the auto filter that i have placed in there without affecting the way the macro is working?

Thanks again
 
Upvote 0
You can only have one criteria for each field at a time, so you would need to repeat the autofilter/delete for the other two.
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,670
Members
449,248
Latest member
wayneho98

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