I have a formating Macro that I want to run on all sheets. Basically the macro hides an unhides certain columns. I my problems are as follows:
1) the nummber and names of the worksheets will change often so I can't just use and arrray to select worksheets(1,3,4,5....)I have dummy sheets which are hidden and placed as the second and last worksheet so I can use a 3D sum formula across all sheets.
I think because these blank sheets are hidden I cannot select all sheets. Ideally,
I need code to select all worksheets except for hidden worksheets and the last worksheet
2) assuming I solve the above, I have tested the macro and and if I go through steps manually, i.e. group all sheets and hide say columns (b:d) these colums are now hidden on all sheets but when I do this throught the the macro it just hides the columns on the active sheet even though the macro groups the sheets. see my test code below
Sub ViewReport2()
Dim ReportKey As String
ReportKey = Range("ReportKey")
Worksheets(Array(1, 3, 4, 5)).Select
Worksheets(1).Activate
Columns("B:EQ").EntireColumn.hidden = True
If ReportKey = 1 Then
Range("B:M,EE:EE").EntireColumn.hidden = False
Range("A77").Select
Else
End If
any ideas?
1) the nummber and names of the worksheets will change often so I can't just use and arrray to select worksheets(1,3,4,5....)I have dummy sheets which are hidden and placed as the second and last worksheet so I can use a 3D sum formula across all sheets.
I think because these blank sheets are hidden I cannot select all sheets. Ideally,
I need code to select all worksheets except for hidden worksheets and the last worksheet
2) assuming I solve the above, I have tested the macro and and if I go through steps manually, i.e. group all sheets and hide say columns (b:d) these colums are now hidden on all sheets but when I do this throught the the macro it just hides the columns on the active sheet even though the macro groups the sheets. see my test code below
Sub ViewReport2()
Dim ReportKey As String
ReportKey = Range("ReportKey")
Worksheets(Array(1, 3, 4, 5)).Select
Worksheets(1).Activate
Columns("B:EQ").EntireColumn.hidden = True
If ReportKey = 1 Then
Range("B:M,EE:EE").EntireColumn.hidden = False
Range("A77").Select
Else
End If
any ideas?