Thursday, January 21, 2016

Excel VBA- Create footer in worksheets

By Ajeet Kumar

CREATE FOOTER AT EACH SHEET

Sub pFooterEachSheet()

    Dim sht As Worksheet

    Dim strMsg As String

    On Error GoTo lblErrFT

    Application.ScreenUpdating = False 
  
    strMsg = "The Footer Text Should be Written Here. "  
 
    For Each sht In ThisWorkbook.Sheets

        sht.Unprotect "MyPassword"

        sht.PageSetup.CenterFooter = "&""Arial,Bold""&12" & strMsg

        sht.Protect Password:="", UserInterfaceOnly:=True

    Next

    Application.ScreenUpdating = True
   
lblErrFT:

If Err <> 0 Then

    MsgBox "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description

End If


End Sub

Hot Topics