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:[TABLE="width: 500"]
<tbody>[TR]
[TD]ID[/TD]
[TD]Field2[/TD]
[TD]Field3[/TD]
[TD]Comment[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]cat[/TD]
[TD]123[/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]dog[/TD]
[TD]3333[/TD]
[TD]Fido[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]#N/A[/TD]
[/TR]
</tbody>[/TABLE]
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?
<tbody>[TR]
[TD]ID[/TD]
[TD]Field2[/TD]
[TD]Field3[/TD]
[TD]Comment[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]cat[/TD]
[TD]123[/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]dog[/TD]
[TD]3333[/TD]
[TD]Fido[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]#N/A[/TD]
[/TR]
</tbody>[/TABLE]
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