PDA

View Full Version : Sleeper: VBA for Page Headers



Pam in TX
07-21-2014, 10:47 AM
I have been trying to find a macro that will have user input which will then populate the headers in an Excel workbook I am working on.

I have one that uses data from another worksheet tab to populate the header, but I would prefer that the user have to input it. I know it's simple but my brain just isn't functioning right now.....

Thank you in advance for your assistance.

ranman256
07-21-2014, 12:16 PM
Sub SetPageHdrs()
Dim vHdr, vDft
vDft = ActiveSheet.PageSetup.CenterHeader
vHdr = InputBox("Enter Header", "Custom Header", vDft)
Application.PrintCommunication = True
With ActiveSheet.PageSetup
.LeftHeader = "" ' left hdr
.CenterHeader = vHdr
.RightHeader = ""
End With
End Sub