Deleting rows based on multiple filter options

Nagartath

New Member
Joined
Sep 15, 2006
Messages
19
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
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

cstimart

Well-known Member
Joined
Feb 25, 2010
Messages
1,180
Does Column A, or any other column have data in it 100% of the time?
 

cstimart

Well-known Member
Joined
Feb 25, 2010
Messages
1,180
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
 

Nagartath

New Member
Joined
Sep 15, 2006
Messages
19
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
 

Nagartath

New Member
Joined
Sep 15, 2006
Messages
19
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
 

cstimart

Well-known Member
Joined
Feb 25, 2010
Messages
1,180
Does Column A contain data for each record 100% of the time?
 

Nagartath

New Member
Joined
Sep 15, 2006
Messages
19
Yes, column A is populated 100% of the time, it contains a unique reference number.
 

cstimart

Well-known Member
Joined
Feb 25, 2010
Messages
1,180
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.
 

Nagartath

New Member
Joined
Sep 15, 2006
Messages
19
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.
 

Forum statistics

Threads
1,089,547
Messages
5,408,881
Members
403,240
Latest member
AlenKovacevic

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top