On a Mac. This code runs fine from the editor but doesn't run from a shape with the macro assigned to it. I tried a few time just to make sure that I was assigning the correct macro.
Thanks in advance!
Thanks in advance!
VBA Code:
Sub ToggleSheetVisibility()
Dim shtName As Range
Dim tabsUpdated As Boolean
tabsUpdated = False
For Each shtName In Range("L18:L42")
On Error Resume Next ' <-- Ignore any sheets that are not found
Dim sht As Worksheet
Set sht = Worksheets(shtName.Value)
If Not sht Is Nothing Then
Dim col As Integer
For col = 11 To 12 ' <-- Loop through columns K to L
If Cells(shtName.Row, col).Value = True Then
sht.Visible = True ' <-- Unhides the sheet
tabsUpdated = True
Exit For
End If
Next col
If col = 13 Then ' <-- None of the cells were true
sht.Visible = False ' <-- Hides the sheet
tabsUpdated = True
End If
End If
Next shtName
If tabsUpdated Then
MsgBox "Tabs were updated"
End If
End Sub
/CODE]