Hide Rows with #N/A error

sc0ttish

New Member
Joined
Aug 22, 2007
Messages
37
Office Version
  1. 365
Hi there,

I'm looking for a macro to hide all rows with a formula error with #N/A.
(or to delete them if thats easier).

I've searched around the forum but the examples elsewhere dont seem to work.
My spreadsheet has various columns with #N/A's in them, the first being column I.

However I have alot of blank rows, when I try to use autofilter it doesn't work due to the breaks.

If anyone can help it would be great.

Thanks
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Perhaps:

Code:
With Sheets("Sheet1")
    On Error Resume Next
    .Columns("I").SpecialCells(xlCellTypeFormulas,xlErrors).EntireColumn.Hidden = True
    On Error GoTo 0
End With

remember that altering row visibility is a volatile action so you may want to toggle calculation & events as part of this process

(to delete modify .Hidden = True to .Delete)

edit:

You mention multiple columns - if you have some rows that will have errors in Col I but not in the other columns let us know - and detail the other columns
 
Upvote 0
Perhaps:

Code:
With Sheets("Sheet1")
    On Error Resume Next
    .Columns("I").SpecialCells(xlCellTypeFormulas,xlErrors).EntireColumn.Hidden = True
    On Error GoTo 0
End With

remember that altering row visibility is a volatile action so you may want to toggle calculation & events as part of this process

(to delete modify .Hidden = True to .Delete)

edit:

You mention multiple columns - if you have some rows that will have errors in Col I but not in the other columns let us know - and detail the other columns


Hi there,

Thanks, gives me a start.
I've done the following, however I get a compile error so changed the End to End Sub and still get the same error.

Any ideas?

Sub DeleteErrors()
With Sheets("Main Brands")
On Error Resume Next
.Columns("I").SpecialCells(xlCellTypeFormulas, xlErrors).EntireColumn.Delete = True
On Error GoTo 0
End With
 
Upvote 0
The With/End With would appear mid Sub - ie the sample was meant as just a snippet to use in whatever routine you may be running:

Code:
Sub DeleteErrors()
    With Sheets("Sheet1")
        On Error Resume Next
        .Columns("I").SpecialCells(xlCellTypeFormulas,xlErrors).EntireRow.Delete
        On Error GoTo 0
    End With
End Sub

note also it should have read EntireRow rather than EntireColumn - oversight on my part I'm afraid - result of trying to multitask.
 
Upvote 0
Thanks,

Ended up going with

Sub Kill_NA()
Columns("I:I").SpecialCells(xlCellTypeFormulas, 16).EntireRow.Delete
End Sub

which runs nice and fast and does the job, cheers again.
 
Upvote 0
It is wise to persist with the Error Handler (and reset) when using SpecialCells

SpecialCells will generate a Debug (if unhandled) should no cells meet specified requirements - eg you run the routine twice in succession (no errors left 2nd time around)
 
Upvote 0
Hello,

Is there a way to do this with Rows? I have following formula in Column A Row 5 through Row 200. Some records will only return three values and others will return 50 values. Seeing #NUM! is distracting and messy. So I am looking to have all Rows with #NUM! hidden.

{=INDEX('CPU ALL DETAILS July 2015'!$A$2:$A$5000,SMALL(IF(Analysis!$B$2='CPU ALL DETAILS July 2015'!$Z$2:$Z$5000,ROW('CPU ALL DETAILS July 2015'!$A$2:$A$5000)-ROW('CPU ALL DETAILS July 2015'!$A$2)+1),ROW(12:12)))}

So if Analysis!$B$2 only returns 5 records I would want Rows 6 through Row 200 hidden.

Thanks
 
Upvote 0
Hello,

Is there a way to do this with Rows? I have following formula in Column A Row 5 through Row 200. Some records will only return three values and others will return 50 values. Seeing #NUM! is distracting and messy. So I am looking to have all Rows with #NUM! hidden.

{=INDEX('CPU ALL DETAILS July 2015'!$A$2:$A$5000,SMALL(IF(Analysis!$B$2='CPU ALL DETAILS July 2015'!$Z$2:$Z$5000,ROW('CPU ALL DETAILS July 2015'!$A$2:$A$5000)-ROW('CPU ALL DETAILS July 2015'!$A$2)+1),ROW(12:12)))}

So if Analysis!$B$2 only returns 5 records I would want Rows 6 through Row 200 hidden.

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,706
Members
452,939
Latest member
WCrawford

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