+ Reply to Thread
Results 1 to 5 of 5

Reference Cell in Page Header Using VBA - Excel 2007

  1. #1
    Registered User
    Join Date
    09-22-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    2

    Reference Cell in Page Header Using VBA - Excel 2007

    Hello, all! I am stumped!

    I have a 150-tab product catalog built in Excel 2007. I want to reference cell A3 (on the tab I have renamed Master) in the header.

    My ultimate desired result: we type in XYZ Company in cell A3 on the Master tab, then all left headers on every tab will read XYZ Company.

    So far, I've tried inserting these in Worksheet Open and Worksheet BeforePrint:
    Please Login or Register  to view this content.

    Can anyone tell me where I'm going wrong with the code and where, exactly, in the VBA editor I'm supposed to insert said code?

    Thanks in advance!!
    Last edited by alansidman; 09-22-2013 at 09:21 PM. Reason: code tags added

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Reference Cell in Page Header Using VBA - Excel 2007

    Hi there!

    Try inserting the following code into a standard VBA Code Module and see if it does what you want:


    Please Login or Register  to view this content.

    If the Company Name is not changed, the above macro needs to be run only once - if the Company Name is changed on a regular basis the "heart" of the above routine can be copied to the "Workbook_BeforePrint" routine.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Last edited by Greg M; 09-22-2013 at 09:20 PM. Reason: Minor typo corrected

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: Reference Cell in Page Header Using VBA - Excel 2007

    mcapril;Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    I have added these for you. Please adhere to our rules in the future.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    09-22-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Reference Cell in Page Header Using VBA - Excel 2007

    I tried inserting what I have quoted below on the VBA Editor Worksheet: BeforePrint and do not see any changes. Is it something I should see populate the header field in page layout view, or will I have to view via print preview in order to see the name?

    Yes, the plan is to change the name on a regular basis so that custom price pages may be printed for various prospects, so what would I need to do to run the macro and update the header, please?

    Many thanks!!


    Quote Originally Posted by Greg M View Post
    Hi there!

    Try inserting the following code into a standard VBA Code Module and see if it does what you want:


    Please Login or Register  to view this content.
    alansidman: I am absolutely embarrassed over here. Thank you for correcting my post. I will pay much more attention next time.
    Last edited by mcapril; 09-22-2013 at 10:20 PM. Reason: Did not edit code to show what I entered

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Reference Cell in Page Header Using VBA - Excel 2007

    Hello again,

    Sorry for the delay in replying.

    Yes, Page Headers and Footers (and therefore also any changes to them) are viewable only in the Print Preview view.

    Including the "heart" of the previous routine in the Workbook_BeforePrint routine will ensure that the Page Header (modified if appropriate) is generated before the worksheet is printed.

    Regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Add cell reference to Page Setup Header
    By jhovey in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-25-2012, 02:36 PM
  2. Reference cell from top row of each page in header
    By mzemble in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-06-2009, 12:45 AM
  3. Adding a Reference to Header/Footer in excel 2007
    By ExcelTip in forum Tips and Tutorials
    Replies: 0
    Last Post: 11-13-2007, 05:33 AM
  4. Excel: can I refer to cell reference in page setup header
    By nikos in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-21-2006, 02:25 PM
  5. Excel header/footer cell reference
    By Paddy in forum Excel General
    Replies: 2
    Last Post: 12-16-2005, 11:35 AM

Tags for this Thread

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