Hide Rows Without Specifying the Row Numbers

megalamchops

New Member
Joined
Mar 31, 2021
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Is it possible to to hide rows based on a cell value of N/A or Not Specified, but without specifying exactly the row number? N/A will always be in the same column and I just want to hide the row N/A is on and the next 3 rows following it. I have a long spreadsheet that is generated so its not the same every time. I don't think it's a good idea to manually specify hundreds of rows to hide.
 
If it is the result of a LOOKUP formula, then that IS actually the result of error that Excel is returning, and not a text value.
That is, unless you actually have the values of N/A in your lookup table, and it is returning that value, and not the #N/A error value it returns when it does not find a match.
So which one is it (it makes a very big difference in how we have to do this)?
Sorry, this is the formula in that cell.

=VLOOKUP($O$1,Sheet1!$A:$CY,MATCH("arbitrary",master_spec[#Headers],0),FALSE)
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Give this macro a try...
VBA Code:
Sub HideErrorRowPlusThreeMoreRows()
  Dim Ar As Range
  For Each Ar In Columns("J").SpecialCells(xlFormulas, xlErrors)
    Ar.Resize(3).Resize(4).EntireRow.Hidden = True
  Next
End Sub
 
Upvote 0
Give this macro a try...
VBA Code:
Sub HideErrorRowPlusThreeMoreRows()
  Dim Ar As Range
  For Each Ar In Columns("J").SpecialCells(xlFormulas, xlErrors)
    Ar.Resize(3).Resize(4).EntireRow.Hidden = True
  Next
End Sub
It seems like it works for the ones that are #N/A, but not the ones that are N/A (Correct me if I'm wrong, I don't think this is an error because I type this value in the lookup table).
 
Upvote 0
So you have a mix of #N/A and N/A??? I don't see the "N/A" in the formula that you posted Message #11... how is the N/A getting into the cells?
 
Upvote 0
So you have a mix of #N/A and N/A??? I don't see the "N/A" in the formula that you posted Message #11... how is the N/A getting into the cells?
I am guessing that the VLOOKUP is working, and there is the literal text "N/A" in the column that they are returning.
 
Upvote 0
Some of the cells are #N/A because I'm still working on the sheet sorry if this wasn't clear. Eventually there won't be any #N/A in the worksheet.

I have a table that =VLOOKUP($O$1,Sheet1!$A:$CY,MATCH("arbitrary",master_spec[#Headers],0),FALSE) is looking at and that specific column it is returning the cells have a value of N/A (I typed N/A, it's not like an IFERROR statement return)


lookup table example
1617644615009.png
 
Upvote 0
Here is a not-so-elegant method that will work:
VBA Code:
Sub HideRows()

    Dim r As Long
    
    Application.ScreenUpdating = False
    
    For r = Cells(Rows.Count, "J").End(xlUp).Row To 1 Step -1
        If Application.WorksheetFunction.IsNA(Cells(r, "J")) Then
            Rows(r & ":" & r + 2).EntireRow.Hidden = True
        Else
            If (Cells(r, "J") = "N/A") Then
                Rows(r & ":" & r + 2).EntireRow.Hidden = True
            End If
        End If
    Next r
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Solution
You are welcome.
Glad we were able to help.
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

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