Hello everyone, I´m trying to activate a macro for my spreadsheet that automatically hides some rows based on a drop down list.
The drop down list has values such as "UHD-HDR" and "UHD-SDR", so I´m not sure they are causing the issue.
The code is the following, but nothing really happens
Could anyone help me understand why is this code not working? I´m using Excel 365 MSO Version 2307.
The drop down list has values such as "UHD-HDR" and "UHD-SDR", so I´m not sure they are causing the issue.
The code is the following, but nothing really happens
VBA Code:
Private Sub HideRowsBasedOnValues(ByVal Target As Range)
Dim ws As Worksheet
Dim cellValue As Range
'Set reference to the worksheet
Set ws = ThisWorkbook.Sheets("Sheet1") 'Change "Sheet1" to your sheet's name
'Read the value from cell B22
Set ws.cellValue = Range("B22")
If Intersect(Target, cellValue) Is Nothing Then Exit Sub
'Unhide all rows before applying hiding
Rows("A29:A50").EntireRow.Hidden = False
'Hide rows based on the value from cell B22
Select Case ws.cellValue
Case Is = ""
Rows("A29:A50").EntireRow.Hidden = False
Case Is = "UHD-HDR"
Rows("A39:A50").EntireRow.Hidden = True
Case Is = "UHD-SDR"
Rows("A29:A38").EntireRow.Hidden = True
End Select
End Sub
Could anyone help me understand why is this code not working? I´m using Excel 365 MSO Version 2307.