+ Reply to Thread
Results 1 to 14 of 14

Macro changes Header/Footer to all worksheets

Hybrid View

  1. #1
    Registered User
    Join Date
    12-19-2009
    Location
    Goldsboro, N
    MS-Off Ver
    Excel 2003
    Posts
    21

    Macro changes Header/Footer to all worksheets

    I'm looking for a macro or VBA code that can copy the header/footer and apply them to other worksheets. I have found code to copy to all worksheets but I only want the next two worksheets to have the copied header/footer and not copy to all the worksheets.

    I have 6 worksheets the first 3 are schedules, the only thing that will be changed in the header/footer will be work periods. example 12/20/09-01/20/10, all other info will be the same. Is there another way to change the dates without having to open each one and manually changing the date. Any thoughts or ideas are welcomed.
    Last edited by RonNCmale; 12-19-2009 at 05:39 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Macro or VBA code to copy Header/Footer to other worksheets but not all.

    Hello,
    could you post what code that you have so far, and possable a sample workbook.

    you say that there are a toatl of 6 worksheets and the 1st 3 sheets are schedules and you only want to copy the header/footer to the next 2 sheets. Do you meant that you only want it copied to the two sheets after the 3 schedules based on their tab location.

    cheers


  3. #3
    Registered User
    Join Date
    12-19-2009
    Location
    Goldsboro, N
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Macro changes Header/Footer to all worksheets

    Here is the workbook and code:

    Sub Macro1()
         '
         ' Macro1 Macro
         ' Macro recorded 07/07/2008 by Gerry McNally
         '
        Dim i As Long
         
        With Worksheets(1).PageSetup
             
            For i = 2 To Worksheets.Count
                 
                Worksheets(i).PageSetup.LeftHeader = .LeftHeader
                Worksheets(i).PageSetup.CenterHeader = .CenterHeader
                Worksheets(i).PageSetup.RightHeader = .RightHeader
                Worksheets(i).PageSetup.LeftFooter = .LeftFooter
                Worksheets(i).PageSetup.CenterFooter = .CenterFooter
                Worksheets(i).PageSetup.RightFooter = .RightFooter
            Next i
        End With
         
    End Sub
    Attached Files Attached Files
    Last edited by RonNCmale; 12-19-2009 at 04:45 AM.

  4. #4
    Registered User
    Join Date
    04-19-2010
    Location
    TN
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Macro changes Header/Footer to all worksheets

    Duplicate post, sorry.
    Last edited by Carrie_Van_Horn; 04-19-2010 at 09:55 PM.

  5. #5
    Registered User
    Join Date
    04-19-2010
    Location
    TN
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Macro changes Header/Footer to all worksheets

    Hi! This is great, I thank you too. Could this be altered to only change the header/footer on selected noncontiguous sheets instead of all of them? I've been trying, can't figure it out. Thanks in advance!


    Quote Originally Posted by RonNCmale View Post
    Here is the workbook and code:

    Sub Macro1()
         '
         ' Macro1 Macro
         ' Macro recorded 07/07/2008 by Gerry McNally
         '
        Dim i As Long
         
        With Worksheets(1).PageSetup
             
            For i = 2 To Worksheets.Count
                 
                Worksheets(i).PageSetup.LeftHeader = .LeftHeader
                Worksheets(i).PageSetup.CenterHeader = .CenterHeader
                Worksheets(i).PageSetup.RightHeader = .RightHeader
                Worksheets(i).PageSetup.LeftFooter = .LeftFooter
                Worksheets(i).PageSetup.CenterFooter = .CenterFooter
                Worksheets(i).PageSetup.RightFooter = .RightFooter
            Next i
        End With
         
    End Sub

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro or VBA code to copy Header/Footer to other worksheets but not all.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro or VBA code to copy Header/Footer to other worksheets but not all.

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro or VBA code to copy Header/Footer to other worksheets but not all.

    Your first thread has managed to break two rules, actually 3 because it is posted in the wrong Forum.
    I suggest you take a few minutes to actually rea the Forum Rules that you agreed to when joining, then make the required edits before posting again.

  9. #9
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Macro changes Header/Footer to all worksheets

    look like you fixed the thread. cheers.

    im a little confused on what you are aming for,
    seams that the workbook is setup for a 4 week peiod. and changing Supervisors A1 should flow though to the other sheets. just update the formular in the weeks 2-4 sheets to =Supervisors!A1+7 week 3 =Supervisors!A1+14 ect.

    if ive missed the mark, ill need you to explain again.

    cheers

  10. #10
    Registered User
    Join Date
    12-19-2009
    Location
    Goldsboro, N
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Macro changes Header/Footer to all worksheets

    If you change the period date in the header on the Supervisor tab and run Macro1 it changes the dates on all the schedules and adds headers to the other sheets. I'm trying to find a solution to only change the first three worksheets headers/footers Supervisor,officer,officer cont and not wk1,wk2,wk3,and wk4

  11. #11
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Macro changes Header/Footer to all worksheets

    ok try changing the line
    For i = 2 To Worksheets.Count
    to
    For i = 2 to 3
    cheers
    Last edited by D_Rennie; 12-19-2009 at 05:22 AM.

  12. #12
    Registered User
    Join Date
    12-19-2009
    Location
    Goldsboro, N
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Macro changes Header/Footer to all worksheets

    Well I'll be a monkeys uncle, that did it. Thanks alot. seems so easy now as I turn red. Again thanks.

  13. #13
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Macro changes Header/Footer to all worksheets

    no probs, glad to help.

    cheers

  14. #14
    Registered User
    Join Date
    01-29-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro changes Header/Footer to all worksheets

    The free Format Copier tool from excelcampus.com automates the process of applying formatting to multiple worksheets in multiple workbooks. It stores your formatted template sheets which you use to apply formatting to unformatted sheets. So all you have to do is open your workbook and press a few buttons, and your worksheets will be formatted exactly like the template. This is great if you're formatting worksheets on a daily basis, and you can specify specific sheets within each workbook.

    It copies page layout options, page breaks, cell and conditional formatting, outlines, groups, freeze panes, column widths, row heights, and more. And allows you to specify which formatting options you want to copy.

    Download it free at http://excelcampus.com/tools/format-copier and check out the video tutorial for more info.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1