![]() |
|
|
|||
|
Re: Referring to Cell in Header
You could use a macro that runs each time you print or print preview.
Option Explicit Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim Wks As Worksheet Set Wks = Me.Worksheets("Sheet1") With Wks .PageSetup.CenterHeader = .Range("A1").Value End With End Sub If you're new to macros: Debra Dalgleish has some notes how to implement macros here: http://www.contextures.com/xlvba01.html David McRitchie has an intro to macros: http://www.mvps.org/dmcritchie/excel/getstarted.htm Ron de Bruin's intro to macros: http://www.rondebruin.nl/code.htm (General, Regular and Standard modules all describe the same thing.) Tami wrote: > > can i refer to a cell in a header...for example if cell A1 says July Week > 1...then it could say that in the header? -- Dave Peterson |
|
|||
|
Re: Referring to Cell in Header
so how do i run the macro or have it automatically run when i print?
i'm used to making macro buttons and assignin a macro or going to tools/macros/run .... "Dave Peterson" wrote: > You could use a macro that runs each time you print or print preview. > > Option Explicit > Private Sub Workbook_BeforePrint(Cancel As Boolean) > Dim Wks As Worksheet > Set Wks = Me.Worksheets("Sheet1") > With Wks > .PageSetup.CenterHeader = .Range("A1").Value > End With > End Sub > > > If you're new to macros: > > Debra Dalgleish has some notes how to implement macros here: > http://www.contextures.com/xlvba01.html > > David McRitchie has an intro to macros: > http://www.mvps.org/dmcritchie/excel/getstarted.htm > > Ron de Bruin's intro to macros: > http://www.rondebruin.nl/code.htm > > (General, Regular and Standard modules all describe the same thing.) > > Tami wrote: > > > > can i refer to a cell in a header...for example if cell A1 says July Week > > 1...then it could say that in the header? > > -- > > Dave Peterson > |
|
|||
|
Re: Referring to Cell in Header
Look at Debra's site for the ThisWorkbook module stuff.
As long as macros are enabled and you haven't disable events, then this will run each time you print/print preview that workbook. Tami wrote: > > so how do i run the macro or have it automatically run when i print? > i'm used to making macro buttons and assignin a macro or going to > tools/macros/run .... > > "Dave Peterson" wrote: > > > You could use a macro that runs each time you print or print preview. > > > > Option Explicit > > Private Sub Workbook_BeforePrint(Cancel As Boolean) > > Dim Wks As Worksheet > > Set Wks = Me.Worksheets("Sheet1") > > With Wks > > .PageSetup.CenterHeader = .Range("A1").Value > > End With > > End Sub > > > > > > If you're new to macros: > > > > Debra Dalgleish has some notes how to implement macros here: > > http://www.contextures.com/xlvba01.html > > > > David McRitchie has an intro to macros: > > http://www.mvps.org/dmcritchie/excel/getstarted.htm > > > > Ron de Bruin's intro to macros: > > http://www.rondebruin.nl/code.htm > > > > (General, Regular and Standard modules all describe the same thing.) > > > > Tami wrote: > > > > > > can i refer to a cell in a header...for example if cell A1 says July Week > > > 1...then it could say that in the header? > > > > -- > > > > Dave Peterson > > -- Dave Peterson |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|