I am running on 2007, how can I combine 4 private sub in one sheet so that it will auto run?
Private Sub worksheet_1()
Dim HiddenRow&, RowRange As Range, RowRangeValue&
'*****************************
'< Set the 1st & last rows to be hidden >
Const firstrow As Long = 56
Const LastRow As Long = 68
'< Set your columns that contain data >
Const FirstCol As String = "B"
Const LastCol As String = "B"
'*****************************
ActiveWindow.DisplayZeros = True
Application.ScreenUpdating = False
For HiddenRow = firstrow To LastRow
'(we're using columns B here)
Set RowRange = Range(FirstCol & HiddenRow & _
":" & LastCol & HiddenRow)
'sums the entries in cells in the RowRange
RowRangeValue = Application.Sum(RowRange.Value)
If RowRangeValue <> 0 Then
'there's something in this row - don't hide
Rows(HiddenRow).EntireRow.Hidden = False
Else
'there's nothing in this row yet - hide it
Rows(HiddenRow).EntireRow.Hidden = True
End If
Next HiddenRow
Application.ScreenUpdating = True
End Sub
Private Sub worksheet_1()
Dim HiddenRow&, RowRange As Range, RowRangeValue&
'*****************************
'< Set the 1st & last rows to be hidden >
Const firstrow As Long = 72
Const LastRow As Long = 87
'< Set your columns that contain data >
Const FirstCol As String = "B"
Const LastCol As String = "B"
'*****************************
ActiveWindow.DisplayZeros = True
Application.ScreenUpdating = False
For HiddenRow = firstrow To LastRow
'(we're using columns B here)
Set RowRange = Range(FirstCol & HiddenRow & _
":" & LastCol & HiddenRow)
'sums the entries in cells in the RowRange
RowRangeValue = Application.Sum(RowRange.Value)
If RowRangeValue <> 0 Then
'there's something in this row - don't hide
Rows(HiddenRow).EntireRow.Hidden = False
Else
'there's nothing in this row yet - hide it
Rows(HiddenRow).EntireRow.Hidden = True
End If
Next HiddenRow
Application.ScreenUpdating = True
End Sub
Private Sub worksheet_1()
Dim HiddenRow&, RowRange As Range, RowRangeValue&
'*****************************
'< Set the 1st & last rows to be hidden >
Const firstrow As Long = 92
Const LastRow As Long = 106
'< Set your columns that contain data >
Const FirstCol As String = "B"
Const LastCol As String = "B"
'*****************************
ActiveWindow.DisplayZeros = True
Application.ScreenUpdating = False
For HiddenRow = firstrow To LastRow
'(we're using columns B here)
Set RowRange = Range(FirstCol & HiddenRow & _
":" & LastCol & HiddenRow)
'sums the entries in cells in the RowRange
RowRangeValue = Application.Sum(RowRange.Value)
If RowRangeValue <> 0 Then
'there's something in this row - don't hide
Rows(HiddenRow).EntireRow.Hidden = False
Else
'there's nothing in this row yet - hide it
Rows(HiddenRow).EntireRow.Hidden = True
End If
Next HiddenRow
Application.ScreenUpdating = True
End Sub
Private Sub worksheet_1()
Dim HiddenRow&, RowRange As Range, RowRangeValue&
'*****************************
'< Set the 1st & last rows to be hidden >
Const firstrow As Long = 113
Const LastRow As Long = 134
'< Set your columns that contain data >
Const FirstCol As String = "B"
Const LastCol As String = "B"
'*****************************
ActiveWindow.DisplayZeros = True
Application.ScreenUpdating = False
For HiddenRow = firstrow To LastRow
'(we're using columns B here)
Set RowRange = Range(FirstCol & HiddenRow & _
":" & LastCol & HiddenRow)
'sums the entries in cells in the RowRange
RowRangeValue = Application.Sum(RowRange.Value)
If RowRangeValue <> 0 Then
'there's something in this row - don't hide
Rows(HiddenRow).EntireRow.Hidden = False
Else
'there's nothing in this row yet - hide it
Rows(HiddenRow).EntireRow.Hidden = True
End If
Next HiddenRow
Application.ScreenUpdating = True
End Sub