Wednesday, 25 September 2013

Excel - Apply macro to all worksheets


Watch step by step example on YouTube

Replace

Sub Test()
'
' Test Macro
'
'
        Cells.Select
        Cells.EntireColumn.AutoFit
        Rows("1:1").Select
        Selection.Font.Bold = True
        With ActiveWindow
            .SplitColumn = 0
            .SplitRow = 1
        End With
        ActiveWindow.FreezePanes = True
        Sheets("Sheet1").Select

End Sub

With

Sub Test()
'
' Test Macro
'

'

Dim ws As Worksheet

    For Each ws In Sheets
        ws.Activate

   
        Cells.Select
        Cells.EntireColumn.AutoFit
        Rows("1:1").Select
        Selection.Font.Bold = True
        With ActiveWindow
            .SplitColumn = 0
            .SplitRow = 1
        End With
        ActiveWindow.FreezePanes = True
        Sheets("Sheet1").Select
    Next ws
End Sub

1 comment:

  1. This was amazing, its seems simple but its a huge help for me and anyone

    ReplyDelete