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?
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

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
 

Watch MrExcel Video

Forum statistics

Threads
1,119,002
Messages
5,575,486
Members
412,669
Latest member
nickyon1
Top