can exel have a header on first page only?

crispee

New Member
Joined
Nov 28, 2005
Messages
3
i just want the header an footer on the first page only!
Can this be done?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
You probably can do this with VBA code

I've never done it, but I think you could get the general gist of it by recording a macro where you put the headers in and then, take them out. And then using the BeforePrint event inside ThisWorkbook with the PrintOut command and specific settings.

I made a quick try of it. I think the syntax needs a little tweaking, but this should get you close.
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    If ActiveSheet.Name = mySheet Then
        With ActiveSheet.PageSetup
            .LeftHeader = ""
            .CenterHeader = ""
            .RightHeader = ""
            .LeftFooter = ""
            .CenterFooter = ""
            .RightFooter = ""
        End With
        Sheets(mySheet).PrintOut(1, 1) = True
        With ActiveSheet.PageSetup
            .LeftHeader = "myText"
            .CenterHeader = "myText"
            .RightHeader = "myText"
            .LeftFooter = "myText"
            .CenterFooter = "myText"
            .RightFooter = "myText"
        End With
        Sheets(mySheet).PrintOut(2) = True
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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