I have a workbook with 3 sheets. I would like to format each sheet the same using VBA (set font size, auto fit columns, sort). I found a piece of code to loop through the sheets:
Sub wsLoop()
' Declare Current as a worksheet object variable.
Dim ws As Worksheet
' Loop through all of the worksheets in the active workbook.
For Each ws In ActiveWorkbook.Worksheets
'Code here
Next ws
End Sub
The original code included a message box that pops up with the sheet name. When inserting the code for formatting that I got from recording a macro, the loop only formatted the first sheet. I have been searching around, but I can't find a simple example. Shouldn't I just be able to drop in:
Cells.Select
With Selection.Font
.Name = "Calibri"
.Size = 9
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Why does this only format the first sheet?