Hi there
I'm successfully using the following code to hide rows that are fixed. However, I want to use this same macro for each day of the week where the row that is hidden is variable depending on which CheckBox is clicked. There are currently 7 checkboxes next to each of the days on the sheet that are positioned 6 rows ABOVE the 2 rows that need to be hidden.
Is there any way of doing this so that I only need one macro which "senses" where the checkbox is located and then hides the appropriate rows relative to the position of the checkbox. I can make 7 macros for each day, but that's not practical or efficient. It also means that should I need to insert/delete a row later, I'll need to change all 7 of the macros with the new row numbers.
I'm successfully using the following code to hide rows that are fixed. However, I want to use this same macro for each day of the week where the row that is hidden is variable depending on which CheckBox is clicked. There are currently 7 checkboxes next to each of the days on the sheet that are positioned 6 rows ABOVE the 2 rows that need to be hidden.
Is there any way of doing this so that I only need one macro which "senses" where the checkbox is located and then hides the appropriate rows relative to the position of the checkbox. I can make 7 macros for each day, but that's not practical or efficient. It also means that should I need to insert/delete a row later, I'll need to change all 7 of the macros with the new row numbers.
Code:
Sub TournamentDay()
Application.EnableEvents = False
Application.ScreenUpdating = False
ActiveSheet.Unprotect
If Rows("15:16").Hidden = True Then
Rows("15:16").Hidden = False
Else
Rows("15:16").Hidden = True
End If
With ActiveSheet
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
.EnableSelection = xlUnlockedCells
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub