Excel VBA Code Not Running with No Error
Hi, I am trying to utilize a VB code in Excel that will hide some rows depending on the value of another cell. In my case, I have a data validation list in cell F42 that gives the user the option of selecting either "Yes" or "No". If the user selects "No", I want to hide rows 43 thru 45. I have followed this https://www.youtube.com/watch?v=NXoh2sgxa-wvideo as a guide, changing only my row numbers and target range. My code is copied below.
The issue that I'm running into is that it doesn't seem like Excel recognizes that that code exists at all. Nothing happens in the spreadsheet when i toggle between "Yes" or "No" in cell F42, and when I click the "Macro" button in the developer tab, it comes up completely empty - like it doesn't even recognize that there is a macro in the worksheet.
The code is "behind" a worksheet in my workbook. I'm using Excel version 2309.
Private Sub HideRows(ByVal Target As Range)
ActiveSheet.Activate
If Not Application.Intersect(Range("F42"), Range(Target.Address)) Is Nothing Then
Select Case Target.Value
Case Is = "No": Rows("43:45").EntireRow.Hidden = True
Case Is = "Yes": Rows("43:45").EntireRow.Hidden = False
End Select
End If
End Sub