Deleting rows based on multiple filter options

rochytall2000

New Member
Joined
Sep 15, 2006
Messages
24
Office Version
  1. 365
  2. 2019
Hi, I need to review a 400,000 row spreadsheet and remove all records where 5 columns are populated with data so I am only eft with records that are missing information.

I haven't got the slightest clue how to go about this using VB.

Any and all help very much appreciated
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I am assuming that Column A has data 100% of the time, and the 5 Columns are B-F

Code:
Sub DeleteIt()
Dim LR As Long
Dim rng As Range
LR = Cells(Rows.Count, 1).End(xlUp).Offset(-1).Row
For Each rng In [A2].Resize(LR)
    If Application.CountBlank(rng.Offset(, 1).Resize(, 5)) = 0 Then
        rng.Clear
    End If
Next rng
On Error Resume Next
    Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0
End Sub
 
Upvote 0
Hi, the impacted columns are:
E
G
I
M
N

I don't know how to upload a file I'm afraid, any help on that would be helpful
 
Upvote 0
Hi CSTIMART, when I run the code it deletes all rows in my database....any suggetions.....I have re-org'ed my spreadsheet to reflect B through to F are the columns I am interested in.

All help greatly appreciated
 
Upvote 0
I am assuming that the 5 cells that are "blank" aren't truly "blank", because the code should only delete rows where all 5 of those cells are blank.
 
Upvote 0
I am assuming that the 5 cells that are "blank" aren't truly "blank", because the code should only delete rows where all 5 of those cells are blank.

Thanks cstimart, I was looking for code to delete the rows where the 5 cells are not blank, if all 5 cells in the row are populated (B thru to F) I want to delete the entire row, if just one of those cells is populated I want to keep the row.

Apologies if I wasn't clear in my original request.
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,665
Members
449,045
Latest member
Marcus05

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