Forum Discussion

Lorenzo Kim's avatar
Lorenzo Kim
Bronze Contributor
May 28, 2018
Solved

print in the middle section of header month, year of a cell

I have A1 with date 5/25/2018 >> upper(text(A1,"mmm")) &", " & text(A1,"yyyy")  would give MAY, 2018 - how do I put this in the middle section of the HEADER for printing purposes?

or add this to text "REPORT FOR" AT THE LEFT SIDE OF THE HEADER...

no need for vba code.. if possible

many thanks

  • Can you change the sheet name to "May, 2018" and then insert sheet name in the header? The procedure may take time but it is is a way without using vba,.

  • Man Fai Chan's avatar
    Man Fai Chan
    Iron Contributor

    Can you change the sheet name to "May, 2018" and then insert sheet name in the header? The procedure may take time but it is is a way without using vba,.

    • Lorenzo Kim's avatar
      Lorenzo Kim
      Bronze Contributor

      Mr. Chan

      I think that is a fantastic way of doing it!!

      MANY MANY THANKS

    • Lorenzo Kim's avatar
      Lorenzo Kim
      Bronze Contributor

      Mr Pieterse

      I think Mr Chan have the right idea.

      Still, many thanks for your time.

      • JKPieterse's avatar
        JKPieterse
        Silver Contributor

        The VBA way is as follows:

        - Right-click the tab of the sheet and choose "View Code"

        - On the left-had side the project pane should be visible. Your current worksheet is highlighted. In that same list, double-click "ThisWorkbook".

        - Paste this code into the window:

        Option Explicit
        
        Private Sub Workbook_BeforePrint(Cancel As Boolean)
            Dim oSh As Object
            For Each oSh In ActiveWindow.SelectedSheets
                oSh.PageSetup.CenterFooter = Format(Date, "mmm yyyy")
            Next
        End Sub
        
    • Lorenzo Kim's avatar
      Lorenzo Kim
      Bronze Contributor

      Mr Pieterse

      Thank you for your reply.

      if it is, kindly help with the VBA code..

      many many thanks

      • Lorenzo Kim's avatar
        Lorenzo Kim
        Bronze Contributor

        Mr Pieterse

        I think Mr Chan have the right idea.

        Still, many thanks for your time..

Resources