Share via

VBA Not working

Anonymous
2012-06-28T19:43:49+00:00

This should place info in the footer but does not. Any ideas?

Sub FormatFooter()

'

' FormatFooter Macro

'

'

    Application.PrintCommunication = False

    With ActiveSheet.PageSetup

        .PrintTitleRows = ""

        .PrintTitleColumns = ""

    End With

    Application.PrintCommunication = True

    ActiveSheet.PageSetup.PrintArea = ""

    Application.PrintCommunication = False

    With ActiveSheet.PageSetup

        .LeftHeader = ""

        .CenterHeader = ""

        .RightHeader = ""

        .LeftFooter = "&""Arial,Regular""&8&F  &D  &T"

        .CenterFooter = ""

        .RightFooter = "&""Arial,Regular""&8&A    Page &P   of &N  "

        .LeftMargin = Application.InchesToPoints(0.7)

        .RightMargin = Application.InchesToPoints(0.7)

        .TopMargin = Application.InchesToPoints(0.75)

        .BottomMargin = Application.InchesToPoints(0.75)

        .HeaderMargin = Application.InchesToPoints(0.3)

        .FooterMargin = Application.InchesToPoints(0.3)

        .PrintHeadings = False

        .PrintGridlines = False

        .PrintComments = xlPrintNoComments

        .PrintQuality = Array(600, 601)

        .CenterHorizontally = False

        .CenterVertically = False

        .Orientation = xlPortrait

        .Draft = False

        .PaperSize = xlPaperLetter

        .FirstPageNumber = xlAutomatic

        .Order = xlDownThenOver

        .BlackAndWhite = False

        .Zoom = 100

        .PrintErrors = xlPrintErrorsDisplayed

        .OddAndEvenPagesHeaderFooter = False

        .DifferentFirstPageHeaderFooter = False

        .ScaleWithDocHeaderFooter = True

        .AlignMarginsHeaderFooter = True

        .EvenPage.LeftHeader.Text = ""

        .EvenPage.CenterHeader.Text = ""

        .EvenPage.RightHeader.Text = ""

        .EvenPage.LeftFooter.Text = ""

        .EvenPage.CenterFooter.Text = ""

        .EvenPage.RightFooter.Text = ""

        .FirstPage.LeftHeader.Text = ""

        .FirstPage.CenterHeader.Text = ""

        .FirstPage.RightHeader.Text = ""

        .FirstPage.LeftFooter.Text = ""

        .FirstPage.CenterFooter.Text = ""

        .FirstPage.RightFooter.Text = ""

    End With

End Sub

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. HansV 462.6K Reputation points
    2012-06-28T20:22:09+00:00

    Try this slighter shorter version:

    Sub FormatFooter()

        Application.PrintCommunication = False

        With ActiveSheet.PageSetup

            .LeftFooter = "&""Arial,Regular""&8&F  &D  &T" & _

                "&R&""Arial,Regular""&8&A    Page &P   of &N"

        End With

        Application.PrintCommunication = False

    End Sub

    Was this answer helpful?

    0 comments No comments