A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
This is easy and as a bonus, it is possible to use the same routine to show / hide the same objects. (Your code shows a difference in the HIDE and SHOW routines, therefor maybe you have to apply only Step 1 as described below to your routines).
Step 1:
Add a Worksheet variable to the header of the sub and use this variable inside instead of ActiveSheet.
Step 2:
Add a Boolean variable to the header and use this variable inside instead of True / False
And here is the sample, I took your routine HIDEINJECTION and and now it looks like this:
Sub HIDE_SHOW_INJECTION(ByVal Ws As Worksheet, ByVal HideState As Boolean)
With Ws
.Rows("41:189").EntireRow.Hidden = HideState
With .Shapes
.Item("Check Box 444").Visible = Not HideState
.Item("Check Box 438").Visible = Not HideState
.Item("Check Box 212").Visible = Not HideState
.Item("Check Box 209").Visible = Not HideState
.Item("Check Box 201").Visible = Not HideState
.Item("Check Box 198").Visible = Not HideState
.Item("Drop Down 197").Visible = Not HideState
.Item("Drop Down 160").Visible = Not HideState
.Item("Drop Down 141").Visible = Not HideState
.Item("Drop Down 139").Visible = Not HideState
.Item("Drop Down 137").Visible = Not HideState
.Item("Drop Down 136").Visible = Not HideState
.Item("Drop Down 92").Visible = Not HideState
.Item("Group Box 55").Visible = Not HideState
.Item("Drop Down 160").Visible = HideState
.Item("Drop Down 160").Visible = Not HideState
.Item("Drop Down 141").Visible = HideState
.Item("Drop Down 141").Visible = Not HideState
.Item("Drop Down 65").Visible = Not HideState
.Item("Drop Down 65").Visible = HideState
.Item("Drop Down 60").Visible = Not HideState
.Item("Check Box 449").Visible = Not HideState
End With
End With
End Sub
As you see there is no SELECTION, SELECT anymore and I've also removed all other unnecessary code.
For a first test your new 2 main routines are this:
Sub HIDEINJECTION()
HIDE_SHOW_INJECTION ActiveSheet, True
End Sub
Sub SHOWINJECTION()
HIDE_SHOW_INJECTION ActiveSheet, False
End Sub
Try them first to be sure they work on your sheet. If everything goes well, the step to run the code in all sheets is very simple:
Sub HIDEINJECTION_AllWorksheets()
Dim Ws As Worksheet
For Each Ws In Worksheets
HIDE_SHOW_INJECTION Ws, True
Next
End Sub
Sub SHOWINJECTION_AllWorksheets()
Dim Ws As Worksheet
For Each Ws In Worksheets
HIDE_SHOW_INJECTION Ws, False
Next
End Sub
Does everything work as desired?
Andreas.