Good morning!
I am using several Select Case commands to hide different rows under differing circumstances in a macro native to a worksheet. I find myself needing to sum the visible cells which would obviously change depending on choices made in other cells. I am aware that Subtotal will work on filtered cells but can't seem to find a way to sum up rows that were not hidden. FYI B1 is a pulldown menu with choices from one to 7
I'd like to be able to just use a formula on this for simplicity. Is there a way to sum only cells that are not hidden?
This is the code I use to hide and un-hide rows
Here is a screenshot of the sample file
[TABLE="width: 704"]
<tbody>[TR]
[TD]Qty of Bedrooms
[/TD]
[TD]7
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD]Shelving Cost
[/TD]
[TD]15.09
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]Total Shelving Cost
[/TD]
[/TR]
[TR]
[TD]14
[/TD]
[TD]14
[/TD]
[TD] YES
[/TD]
[TD]14
[/TD]
[TD] Solid Core
[/TD]
[TD] $ 211.26
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]14
[/TD]
[TD]12
[/TD]
[TD] YES
[/TD]
[TD]14
[/TD]
[TD] Solid Core
[/TD]
[TD] $ 211.26
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]12
[/TD]
[TD]12
[/TD]
[TD] YES
[/TD]
[TD]12
[/TD]
[TD] Hollow Core
[/TD]
[TD] $ 181.08
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]12
[/TD]
[TD]10
[/TD]
[TD] YES
[/TD]
[TD]12
[/TD]
[TD] Hollow Core
[/TD]
[TD] $ 181.08
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]10
[/TD]
[TD]10
[/TD]
[TD] YES
[/TD]
[TD]10
[/TD]
[TD] Bi-Fiold
[/TD]
[TD] $ 150.90
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]10
[/TD]
[TD]10
[/TD]
[TD] YES
[/TD]
[TD]10
[/TD]
[TD] Bi-Fiold
[/TD]
[TD] $ 150.90
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]10
[/TD]
[TD]10
[/TD]
[TD] YES
[/TD]
[TD]10
[/TD]
[TD] Bi-Fiold
[/TD]
[TD] $ 150.90
[/TD]
[/TR]
</tbody>[/TABLE]
Thanks very much for any suggestions or thoughts that might help
Bill
I am using several Select Case commands to hide different rows under differing circumstances in a macro native to a worksheet. I find myself needing to sum the visible cells which would obviously change depending on choices made in other cells. I am aware that Subtotal will work on filtered cells but can't seem to find a way to sum up rows that were not hidden. FYI B1 is a pulldown menu with choices from one to 7
I'd like to be able to just use a formula on this for simplicity. Is there a way to sum only cells that are not hidden?
This is the code I use to hide and un-hide rows
Code:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = True
Rows("4:17").EntireRow.Hidden = False
Select Case Range("B1")
Case "1"
Rows("6:17").EntireRow.Hidden = True
Case "2"
Rows("8:17").EntireRow.Hidden = True
Case "3"
Rows("10:17").EntireRow.Hidden = True
Case "4"
Rows("12:17").EntireRow.Hidden = True
Case "5"
Rows("14:17").EntireRow.Hidden = True
Case "6"
Rows("16:17").EntireRow.Hidden = True
End Select
End Sub
Here is a screenshot of the sample file
[TABLE="width: 704"]
<tbody>[TR]
[TD]Qty of Bedrooms
[/TD]
[TD]7
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD]Shelving Cost
[/TD]
[TD]15.09
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]Total Shelving Cost
[/TD]
[/TR]
[TR]
[TD]14
[/TD]
[TD]14
[/TD]
[TD] YES
[/TD]
[TD]14
[/TD]
[TD] Solid Core
[/TD]
[TD] $ 211.26
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]14
[/TD]
[TD]12
[/TD]
[TD] YES
[/TD]
[TD]14
[/TD]
[TD] Solid Core
[/TD]
[TD] $ 211.26
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]12
[/TD]
[TD]12
[/TD]
[TD] YES
[/TD]
[TD]12
[/TD]
[TD] Hollow Core
[/TD]
[TD] $ 181.08
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]12
[/TD]
[TD]10
[/TD]
[TD] YES
[/TD]
[TD]12
[/TD]
[TD] Hollow Core
[/TD]
[TD] $ 181.08
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]10
[/TD]
[TD]10
[/TD]
[TD] YES
[/TD]
[TD]10
[/TD]
[TD] Bi-Fiold
[/TD]
[TD] $ 150.90
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]10
[/TD]
[TD]10
[/TD]
[TD] YES
[/TD]
[TD]10
[/TD]
[TD] Bi-Fiold
[/TD]
[TD] $ 150.90
[/TD]
[/TR]
[TR]
[TD]BedroomWidth
[/TD]
[TD]Bedroom Length
[/TD]
[TD] Closet Y/N
[/TD]
[TD]Closet Width
[/TD]
[TD] Type of Doors
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]10
[/TD]
[TD]10
[/TD]
[TD] YES
[/TD]
[TD]10
[/TD]
[TD] Bi-Fiold
[/TD]
[TD] $ 150.90
[/TD]
[/TR]
</tbody>[/TABLE]
Thanks very much for any suggestions or thoughts that might help
Bill