View Single Post
  #5   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 07:38:43 -0800 (PST) schrieb JeanPierre Charron:

Thank you again, but if cells equal -50, 50,0,0 the sum would equal 0 but this row
would not would not be hideable because I have negative and positive values
cancelling each other in Col B and C in this case.


try:
Private Sub CommandButton1_Click()
Dim LRow As Long
Dim i As Long
Dim myCount As Long

With ActiveSheet
If .CommandButton1.Caption = "Hide" Then
LRow = .UsedRange.Rows.Count
For i = 1 To LRow
myCount = WorksheetFunction.Count(.Range(.Cells(i, 2), _
.Cells(i, 5)))
If myCount = 0 Or WorksheetFunction.CountIf _
(.Range(.Cells(i, 2), .Cells(i, 5)), 0) = myCount Then
Rows(i).Hidden = True
.CommandButton1.Caption = "Unhide"
End If
Next
Else
.UsedRange.EntireRow.Hidden = False
.CommandButton1.Caption = "Hide"
End If
End With

End Sub

I am from Saarbrücken in Germany ;-)


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