Filter-delete #N/A in one column, ONLY IF all other columns blank?

Gingertrees

Well-known Member
Joined
Sep 21, 2009
Messages
697
I have a spreadsheet where a "comment" section tends to have 100s of rows of trailing "#N/A"s. My initial thought was simply to filter on the comment column and delete those rows. But sometimes there is an #N/A in a row that has other useful info. To better explain:
IDField2Field3Comment
1cat123#N/A
2dog3333Fido
#N/A
#N/A

<tbody>
</tbody>
Since other columns in row 2 have info, I do not want to delete row 2 despite the error in the comment section. The last two rows, however, are useless and could be deleted.

Here is my code to delete #N/A in field 4 (comment). How do I change this to filter out ones where the other columns are NOT blank?
Code:
    FullrangeII.AutoFilter field:=4, Criteria1:="#N/A", Operator:=xlAnd
    '//////Field 4=comments. Tweak as necessary.
    
    ActiveSheet.Range("A3:EE" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    ActiveSheet.ShowAllData
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hello

You may loop through all the columns and filter by blank. After which delete the visible cells.

Code:
Dim i As Integer
'// Loop through each column and filter by blank (Column A to C)
For i = 1 To 3
    FullrangeII.AutoFilter field:=i, Criteria1:="", Operator:=xlAnd
Next i
'// Filter Comment Column for #N/A (Column D)
    FullrangeII.AutoFilter field:=4, Criteria1:="#N/A", Operator:=xlAnd
'// Delete Visible cells after filter
    Range("A3:EE" & lastrow).SpecialCells(xlCellTypeVisible).EntireRow.Delete
'//Remove filter
    ActiveSheet.AutoFilterMode = False
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,086
Members
449,206
Latest member
ralemanygarcia

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