Header on page 2+ only

  • ok i need my header to print only on pages 2+. i have a partial code... but it isnt mine (i copied it off of a website). i just need to know why it wont work... btw this is the first code i have delt with and the fisrt time i have used vba. where it says ("My Sheet") do i need to put (Sheet4) ? is there somethign wrong with my first line im looking at it right now and it has a yellow arrow pointing to it and it is hilighted. i just need to know what i have to change to get it to work. thank you

    Public Sub NoFirstPageHeader_OneSheet()
            Dim sHeader As String
            With Sheets("My sheet")
                sHeader = .PageSetup.CenterHeader
                .PageSetup.CenterHeader = ""
                .PrintOut From:=1, To:=1
                .PageSetup.CenterHeader = sHeader
                .PrintOut From:=2
            End With
        End Sub
  • Re: Header on page 2+ only

    It works fine for me. Copy the code into a module. Then make a command button in a sheet. make sure the sheet you want to print is named "My Sheet" without the quotes. which is what the line:

    With Sheets("My sheet")

    is referring to.

    Then go put this line under the commandbutton1 click :

    Call NoFirstPageHeader_OneSheet

    now you can click the button and it should work

  • Re: Header on page 2+ only

    thank you very much sir. works great. i feel like a pro and its the first thing i have done with visual basic. (even though i know i am not a pro at all considering the difficulty level of what i was trying to accomplish.

    thanks again Brister

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!