Auto-hide rows based on multiple cell value

AYSHANA

Board Regular
Joined
Oct 16, 2021
Messages
90
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
great day!

can anyone help me with my code, im trying to hide based on multiple cells, but unfortunately it will hang, i dont know what mistakes im doing.

thanks alot.


Private Sub WORKSHEET_Calculate()

Dim Result, Test As Range

Set Result = Range("E11")
Set Test = Range("H11")


Select Case Result


Case Is = "Acceptable": Rows("14:83").EntireRow.Hidden = True

Case Is = "Acceptable with Bias": Rows("14:83").EntireRow.Hidden = True

Case Is = "Unacceptable": Rows("56:80").EntireRow.Hidden = True
Rows("14:53").EntireRow.Hidden = False


Case Is = "Acceptable ungarded": Rows("14:53").EntireRow.Hidden = True

Rows("56:80").EntireRow.Hidden = False

End Select

Select Case Test

Case Is = "-": Rows("14:83").EntireRow.Hidden = True



Case Is = "Qualitative": Rows("14:53").EntireRow.Hidden = True

Rows("67:79").EntireRow.Hidden = True
Rows("56:64").EntireRow.Hidden = False


Case Is = "Quantitative": Rows("14:64").EntireRow.Hidden = True

Rows("67:79").EntireRow.Hidden = False



End Select


End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I would think you should use a sheet change event script and not a calculate script:
Like this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  11/19/2022  12:49:01 AM  EST
Dim Result, Test As Range
Set Result = Range("E11")
Set Test = Range("H11")

Select Case Result
    Case Is = "Acceptable": Rows("14:83").EntireRow.Hidden = True
    Case Is = "Acceptable with Bias": Rows("14:83").EntireRow.Hidden = True
    Case Is = "Unacceptable": Rows("56:80").EntireRow.Hidden = True
    Rows("14:53").EntireRow.Hidden = False

        Case Is = "Acceptable ungarded": Rows("14:53").EntireRow.Hidden = True
            Rows("56:80").EntireRow.Hidden = False
End Select

Select Case Test
    Case Is = "-": Rows("14:83").EntireRow.Hidden = True
    Case Is = "Qualitative": Rows("14:53").EntireRow.Hidden = True
        Rows("67:79").EntireRow.Hidden = True
        Rows("56:64").EntireRow.Hidden = False

    Case Is = "Quantitative": Rows("14:64").EntireRow.Hidden = True
        Rows("67:79").EntireRow.Hidden = False

End Select

End Sub
 
Upvote 0
Solution
If my suggestion does not work, please explain what is not working the way you want
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,432
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top