dimanche 3 avril 2022

VBA code only works when I click on a cell in the sheet?

I used checkboxes, when clicked depending on which checkbox is selected, specific rows unhide. Code runs fine. Only issue is that code is not triggered by clicking the checkbox but works when I select any cell in the sheet.

Below is some of the code used:

 Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 ActiveSheet.Activate

 If Range("C2").Value Or Range("C3").Value Or Range("C4").Value Or Range("C5").Value Or Range("C6").Value Or Range("C7").Value Or Range("C8").Value Or Range("C9").Value Then

Rows("39:52").EntireRow.Hidden = False
Rows("166:169").EntireRow.Hidden = False
Rows("173:175").EntireRow.Hidden = False
 
 Else

 Rows("39:52").EntireRow.Hidden = True
 Rows("166:169").EntireRow.Hidden = True
 Rows("173:175").EntireRow.Hidden = True

 End If


 End Sub



Aucun commentaire:

Enregistrer un commentaire