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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

bk

Active Member
Joined
Jun 2, 2002
Messages
387
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,499
Messages
5,832,067
Members
430,109
Latest member
tinezi

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
Top