I'm trying to hide rows in multiple ranges in a sheet. I can't seem to get it to work completly. Listed below is the code. I've defined the sections of what I want to hide and I want to only hide the rows that are 6(7) rows in and stop at 'Total'. I was able to get this work partially but not anymore. I was also never able to hide the rows in the closings section.
Can someone take a look and see what I'm missing. Any help is much appreciated.
Can someone take a look and see what I'm missing. Any help is much appreciated.
Code:
Sub Hide_Sum_Unused_Rows_Starts()
'
Dim Category2 As String
Dim Row_Start As Integer
Dim RngToSum As Range
'
'Hide Rows in Starts
'
Range("Starts.Summary").Select
Row_Start = ActiveCell.Row + 7
'
'Check for values in row and hide if zero
'
Do Until Category2 = "Total"
Set RngToSum = Sheets("Summaries").Range("A" & Row_Start & ":AZ" & Row_Start)
If Application.WorksheetFunction.Sum(RngToSum) = 0 Then
Range("A" & Row_Start).Select
Selection.EntireRow.Hidden = True
Else
End If
Loop
'
'Sales Section
'
Set RngToSum = Sheets("Summaries").Range("Sales.Summary")
If Application.WorksheetFunction.Sum(RngToSum) = 0 Then
Range("Sales.Summary").Select
Selection.EntireRow.Hidden = True
Else
Range("Sales.Summary").Select
Row_Start = ActiveCell.Row + 6
'
Do Until Category2 = "Total"
Set RngToSum = Sheets("Summaries").Range("A" & Row_Start & ":AC" & Row_Start)
If Application.WorksheetFunction.Sum(RngToSum) = 0 Then
Range("A" & Row_Start).Select
Selection.EntireRow.Hidden = True
Else
End If
Loop
'
'Closings Section
'
Set RngToSum = Sheets("Summaries").Range("Closings.Summary")
If Application.WorksheetFunction.Sum(RngToSum) = 0 Then
Range("Closings.Summary").Select
Selection.EntireRow.Hidden = True
Else
Range("Closings.Summary").Select
Row_Start = ActiveCell.Row + 6
'
Do Until Category2 = "Total"
Set RngToSum = Sheets("Summaries").Range("A" & Row_Start & ":AC" & Row_Start)
If Application.WorksheetFunction.Sum(RngToSum) = 0 Then
Range("A" & Row_Start).Select
Selection.EntireRow.Hidden = True
Else
End If
Loop
'
'Lot Closings Section
'
Set RngToSum = Sheets("Summaries").Range("Lot.Closings.Summary")
If Application.WorksheetFunction.Sum(RngToSum) = 0 Then
Range("Lot.Closings.Summary").Select
Selection.EntireRow.Hidden = True
Else
Range("Lot.Closings.Summary").Select
Row_Start = ActiveCell.Row + 6
'
Do Until Category2 = "Total"
Set RngToSum = Sheets("Summaries").Range("A" & Row_Start & ":AC" & Row_Start)
If Application.WorksheetFunction.Sum(RngToSum) = 0 Then
Range("A" & Row_Start).Select
Selection.EntireRow.Hidden = True
Else
End If
Loop
End Sub
Last edited by a moderator: