printing header from VBA

jab973

New Member
Joined
Feb 13, 2015
Messages
11
Office Version
  1. 365
Platform
  1. Windows
I have a macro to set up print ranges (there are multiple ranges on each tab) Another macro calls the print range macro and then prints. My header references cell J1, which is a named range, and J2, which is =now() It does not print when I run the second macro.

code to set up print range
Sub PrintCorpCap()
Application.PrintCommunication = False
With Sheet164.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = "$a:$c"
.PrintArea = "$D$1:$e$49"
.RightHeader = Range("J1").Value & Chr(13) & Range("J2").Value
.RightFooter = "&G"
.Orientation = xlPortrait
.BlackAndWhite = True
.Zoom = 90
End With
Application.PrintCommunication = True
End Sub
/code


code to print out page
Private Sub USFPrintButton_Click()
Application.CalculateFull
Application.ScreenUpdating = False

If chk1.Value = True Then
Call PrintCorpCap
Sheet164.PrintOut
End If


~ Application.ScreenUpdating = True
End Sub
/code

If I run the first macro and print manually, the header is there. When I use the second macro to print, the header is not there. Any ideas what I'm doing wrong?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Where is USFPrintButton physically placed?
 
Upvote 0
Oh, yes, you just answered my question! The print button is on another tab, so I see now that I need to add the header to the that tab. Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,126
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top