Forum Discussion
Lorenzo Kim
May 27, 2018Bronze Contributor
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...
- May 28, 2018
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,.
JKPieterse
May 28, 2018Silver Contributor
This can only be done using some VBA code I'm afraid.
- Lorenzo KimMay 28, 2018Bronze Contributor
Mr Pieterse
I think Mr Chan have the right idea.
Still, many thanks for your time.
- JKPieterseMay 28, 2018Silver 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 KimMay 28, 2018Bronze Contributor
Mr. Pieterse
THANK YOU VERY MUCH FOR YOUR REPLY
- Lorenzo KimMay 28, 2018Bronze Contributor
Mr Pieterse
Thank you for your reply.
if it is, kindly help with the VBA code..
many many thanks
- Lorenzo KimMay 28, 2018Bronze Contributor
Mr Pieterse
I think Mr Chan have the right idea.
Still, many thanks for your time..