Reputation: 69
I'm hiding or unhiding rows in a workbook based on checkboxes at the top of Sheet2. Enable a box and a set of rows is unhidden, and vice versa across multiple sheets.
To speed things up, Sheet1 has a number of buttons that are used to configure the workbook by filling in data in key cells, and stating which checkboxes are enabled and which aren't on Sheet2.
A typical button's code on Sheet1 is:
Sub Setup()
Worksheets("Sheet2").CheckBoxes("Check Box 101").Value = 1
Call CheckBox101_Click
This sets the checkbox value to 1 or true, and then runs the code which hides or unhides rows based on the checkbox state.
And the checkbox code:
Sub CheckBox101_Click()
Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet2")
Worksheets("Sheet2").Range("A11:A35").EntireRow.Hidden = Not ws.CheckBoxes("Check Box 101") = 1
Worksheets("Sheet3").Range("A37").EntireRow.Hidden = Not ws.CheckBoxes("Check Box 101") = 1
Manually clicking the checkbox works just fine with this code, but running it via the Setup macro hides everything perfectly on Sheet3, but not on Sheet2 for some reason.
Any suggestions to update the Checkbox101 sub code to hide or unhide the rows on Sheet2 as well?
Upvotes: 0
Views: 528
Reputation: 69
Well, picking up where I left off editing and everything is working just fine. Guess closing the file and re-opening it solved it.
One of those weird Excel behaviors perhaps ...
Upvotes: 0