Dynamic Header

J

JAbels001

Hi! I have a worksheet where I need the Header to change based on a cell
value(V4)... Is this possible? I have worked through several VBA's but they
dont seem to do the trick. Thanks for any help!
 
B

Barb Reinhardt

I've done this with Workbook_BeforePrint Macro. Put this in the ThisWorkbook
Module.

Sub Workbook_BeforePrint(Cancel As Boolean)

'The headers are updated to include the program name and the last save time
'each time the workbook is printed

Application.ScreenUpdating = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ActiveSheet.Range("V4").text
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.CenterHorizontally = True
.CenterVertically = False
End With
Application.ScreenUpdating = True
End Sub
 
S

Shane Devenshire

Hi,

Add this one line to a BeforePrint macro

ActiveSheet.PageSetup.LeftHeader = [V4]
 
J

JAbels001

That VBA isnt working for me. Is it possible that I setup it up wrong? It's
placed on the tab I need to print as General... Is there anything else?
 
J

JAbels001

I got it to work! Thanks!

Shane Devenshire said:
Hi,

Add this one line to a BeforePrint macro

ActiveSheet.PageSetup.LeftHeader = [V4]

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


JAbels001 said:
Hi! I have a worksheet where I need the Header to change based on a cell
value(V4)... Is this possible? I have worked through several VBA's but they
dont seem to do the trick. Thanks for any help!
 
Top