I am trying to create a Toggle Button that will hide rows that are unused on two worksheets in a workbook. I have gotten the code to work on one worksheet mostly. Due to formatting I was checking each range which is basically a separate table and then hiding that row. However cells A46:A62 are tied to cells A6:A22 with simple A46=A6 formulas and these rows never hide. Below is the code for the toggle that I am using:
Private Sub ToggleButton1_Click()
If ToggleButton1 Then
Dim r As Range, c As Range
Set r = Range("A6:A22")
Application.ScreenUpdating = False
For Each cell In Range("a6:a22")
cell.EntireRow.Hidden = cell.Value = ""
Next cell
For Each cell In Range("a28:a40")
cell.EntireRow.Hidden = cell.Value = ""
Next cell
For Each cell In Range("a46:a62")
cell.EntireRow.Hidden = cell.Value = ""
Next cell
For Each cell In Range("a66:a100")
cell.EntireRow.Hidden = cell.Value = ""
Next cell
Else
Rows("6:100").EntireRow.Hidden = False
Application.ScreenUpdating = True
End If
End Sub
I would also like to make this one toggle located on Sheet1 hide the same rows on Sheet2 if that is possible.