Adding a formula to a header is it possible?

anill

New Member
Joined
Nov 22, 2004
Messages
13
Hi,
I am doing a roster for shift work in a hospital. I have the date, type of shift as the columns. Each page has the roster for a month. I want the Month to appear as the header on each page. eg page 2 is November and I want the header to appear as Roster for November. Is this possible? Thanks in advance to all who are willing to help.
Regards
Dr AP
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
If each page is on a different sheet then:
The easy way is to name the page "Roster for November". Then in the header, choose the name from the drop-down list.

If they are on the same sheet, try this:
Sub Macro1()
StartPrint = "A2"
Range("A3").Select
ActiveSheet.ResetAllPageBreaks
MonthRef = Month(ActiveCell)
MonthRef1 = Format(ActiveCell, "mmmm")
With ActiveSheet.PageSetup
.CenterHeader = "Roster for " & MonthRef1
End With
Do Until ActiveCell.Text = ""
MonthRef = Month(ActiveCell)
MonthRef1 = Format(ActiveCell, "mmmm")
If Month(ActiveCell.Offset(-1, 0)) = MonthRef Then
Else
EndPrint = ActiveCell.Offset(-1, 2).Address
Range(StartPrint & ":" & EndPrint).PrintOut
StartPrint = ActiveCell.Offset(1, 0).Address
End If
ActiveCell.Offset(1, 0).Select
Loop
StartPrint = ActiveCell.Offset(-3, 0).Address
With ActiveSheet.PageSetup
.CenterHeader = "Roster for " & MonthRef1
End With
EndPrint = ActiveCell.Offset(0, 2).Address
Range(StartPrint & ":" & EndPrint).PrintOut
End Sub
 
Upvote 0
One way;
Name the sheet "Roster for November"
Then use custom header and select "Tab"

anill said:
Hi,
I am doing a roster for shift work in a hospital. I have the date, type of shift as the columns. Each page has the roster for a month. I want the Month to appear as the header on each page. eg page 2 is November and I want the header to appear as Roster for November. Is this possible? Thanks in advance to all who are willing to help.
Regards
Dr AP
 
Upvote 0
Hi,
Thank you for your reply, very much appreciated. I will try and put the monthly rota into individual sheets. The other solution must be a macro / vba which I know nothing about :cry: may be in a few years time I wil make more sense of it.
Dr AP
 
Upvote 0

Forum statistics

Threads
1,215,038
Messages
6,122,798
Members
449,095
Latest member
m_smith_solihull

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