View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Hide / Unhide each row from StartRow to LastRow for multiple conditions

hi J.P.,

Am Sat, 31 Jan 2015 16:08:36 +0100 schrieb Claus Busch:

Sub Hide()


if you want to do it with a button insert an activeX button into the
sheet and change its caption to Hide.
Then insert following code into the CommandButton1_click event:

Private Sub CommandButton1_Click()
Dim varData As Variant
Dim i As Long

With ActiveSheet
If .CommandButton1.Caption = "Hide" Then
varData = Intersect(.UsedRange, .Range("B:E"))
For i = 1 To UBound(varData)
If Application.Sum(Application.Index(varData, i, 0)) = 0 Then
.Rows(i).Hidden = True
End If
Next
.CommandButton1.Caption = "Unhide"
Else
.UsedRange.EntireRow.Hidden = False
.CommandButton1.Caption = "Hide"
End If
End With

End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional