I tweaked this for another set of pages, it works good, but if a page is visible it hides it, then I get it error.
Is there any way that it can ignore sheets that are visible and then hide all the visble ones after it has deleted what needs to be deleted?
Sub ClearDailys()
'
' ClearDailys Macro
'
'
Call SheetHider '(unhides the sheets)
'here goes the code for printing or something else
Dim i As Integer
Dim str As String
For i = 1 To 31
str = "Daily (" & i & ")"
Sheets(str).Select
Range("B4:B11,D4:D8,D10,F3,B14:F38").Select
Range("B14").Select
Range("B4:B11,D4:D8,D10,F3,B14:F38,E41:L50,a41:a50").Select
Range("E41").Activate
Selection.ClearContents
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Next i
Call SheetHider '(hides the sheets)
End Sub
Sub SheetHider()
'if all the worksheet names are similar as in your example
'like this: Sheets("Don't Unhide Motor Report (1)")
'then you can do it a little easier
Dim i As Integer
Dim str As String
For i = 1 To 31
str = "Daily (" & i & ")"
Sheets(str).Visible = Not Sheets(str).Visible
Next i
End Sub
Bookmarks