View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Conditional Formatting to Hide Rows or Columns?

An example of hiding a row based on a value in any formula cell in Column A

Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim cell As Range
Application.ScreenUpdating = False
With ActiveSheet.UsedRange
.Rows.Hidden = False
For Each cell In .Columns(1).SpecialCells(xlCellTypeFormulas)
If cell.text = "" Or cell.Value = 0 Then cell.EntireRow.Hidden = True
Next cell
End With
End Sub

This is event code.

Right-click on the sheet tab and copy/paste into that module.


Gord Dibben MS Excel MVP

On Wed, 27 Sep 2006 00:15:34 +0100, sczegus
wrote:


I'm currently using Excel 2002 SP3. I use conditional formatting in many
of my spreadsheets, but I haven't been able to figure out how to "Hide"
a row or column based on a certain condition. Is there a method for
doing this already built into Excel's functionality, and if not, is
there a way to do it with VBA? Any help would be greatly appreciated!
Thank you.