Select all visible sheets in a workbook
Dim ws As Worksheet
For Each ws In Sheets
If ws.Name <> "SOURCE DATA" And ws.Visible Then ws.Select (False)
Next
End Sub
Sub RefreshAllPivots()
Dim ws As Worksheet
Dim pt As PivotTable
On Error Resume Next
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next
Next
End Sub
Hide All But One Sheet
Loop through all sheets in a Workbook and hide all but Sheet1. Excel will not allow all sheets hidden.
'We must leave at least one Sheet visible
Dim wsSheet As Worksheet
For Each wsSheet In Worksheets
wsSheet.Visible = wsSheet.Name = "Sheet1"
Next wsSheet
End Sub
Clear the content (empty) all unprotected cells in a protected sheet!
This comes in very handy when you want to be able to clear all input fields in a template you have built and protected.
Note: make sure you only run this macro if your sheet is protected, otherwise it clears everything..