Thread: Auto Hide
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mark Henri Mark Henri is offline
external usenet poster
 
Posts: 3
Default Auto Hide

I want to set up my Excel form so that when the user is finished entering
the data, Excel hides columns/rows that don't have data in them. For
example, if I set it up for 10 rows, but the user only needs 4 rows, they
would hit a button (triggering a macro) and the 6 unused rows would be
hidden (or deleted.)

Try something like this--

Private Sub HideRows()
Dim c As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each c In Range("a10:a20")
If c.Value = 0 Then
c.EntireRow.Hidden = True
Else
c.EntireRow.Hidden = False
End If
Next c
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub