I have a macro that works perfectly well when triggered on an onchange event. It simply checks a cell value and hides or unhides rows elsewhere on the same active sheet. Here is the macro that hides or unhides rows:
Sub ToggleTaskTable()
MsgBox "Toggling Tasks"
If Cells(56, 3).Value = "No" Then
Cells(57, 1).EntireRow.Hidden =
MsgBox "Hding Rows 106, 148 and 190"
ActiveSheet.Rows("106").Hidden = True
ActiveSheet.Rows("148").Hidden = True
ActiveSheet.Rows("190").Hidden = True
' try it another way
Rows("106").Hidden = True
Rows("148").Hidden = True
Rows("190").Hidden = True
Else
Cells(57, 1).EntireRow.Hidden = False
' MsgBox "Showing task Rows 106, 148 and 190"
Rows("106").Hidden = False
Rows("148").Hidden = False
Rows("190").Hidden = False
End If
End Sub
If I call the macro as a result of changing a cell C56
to "No", it works perfectly.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$56" Then
Call ToggleTaskTable
End If
End Sub
If I call the macro from another macro, with C56
set to "No", it does not work at all.
Sub CallAllMacros()
Call ToggleTaskTable
End Sub
Even though the msgbox shows indicating it is hiding the rows, it does not actually hide them.
I am totally stumped!