You are here:

- Home
- Computing/Technology
- Business Software
- Excel
- Hide Rows with Errors

Advertisement

Excel 2010

You answered a question about Hiding Rows by using a MACRO as noted below. I want to hide rows that have errors in them. I have an INDEX formula in a multi-sheet workbook and some of the criteria doesn't always exist, so I want to hide the rows with #N/A. The column that has the error is "I"

My Formula (though I don't think you need it) =INDEX(SUPINC!$A$11:$J$400, MATCH(C13,SUPINC!$B$11:$B$400,), MATCH("Variance 2",SUPINC!$A$11:$J$11,))

YOUR PREVIOUS ANSWER from 2004

You can certainly run a macro. You haven't said which column to key on, but assume column E

Sub HideRows()

Dim cell as Range, rng as Range

Cells.Rows.Hidden = False

On error resume Next

set rng = Columns(5).SpecialCells(xlConstants,xlNumbers)

ON Error goto 0

for each cell in rng

if cell.Value = 0 then

cell.EntireRow.Hidden = True

end if

Next

End Sub

the argument xlconstants assumes constant values in the column. If the values are produced by formula, then use xlFormulas rather than xlConstants.

conditional formatting can not hide or unhide rows.

You could also apply a filter, such as the Autofilter under the Data menu. Even though the name Autofilter implies the filtering would be dynamic, it is not. You have to apply the filter, but that is not (if you are not familiar with autofilter).

--

Regards,

Tom Ogilvy

Kim,

Believe this should work. It unhides all the hidden rows first incase a hidden row should now be unhidden. If you don't want that then comment out

Cells.EntireRow.Hidden = False

by preceding with a single quote

'Cells.EntireRow.Hidden = False

Sub HideRows()

Dim rng as Range

Cells.Rows.Hidden = False

On error resume Next

' column I is column 9

set rng = Columns(9).SpecialCells(xlFormulas, xlErrors)

On Error goto 0

if not rng is nothing then

rng.Entirerow.Hidden = True

End if

End Sub

--

Regards,

Tom Ogilvy

- Add to this Answer
- Ask a Question

Rating(1-10) | Knowledgeability = 10 | Clarity of Response = 10 | Politeness = 10 |

Comment | Thanks, Tom! You're a genius! It worked perfectly. |

This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

Answers by Expert:

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

Extensive experience. **Education/Credentials**

Master of Science (MS) degree Operations Research (ORSA)**Awards and Honors**

Microsoft MVP in Excel.