SOLVED

Auto Populate Header Using Another Sheet

Copper Contributor

For years I have been struggling with a document that I change several times a month, and know there is an easier way to solve this issue. It seems like auto populating a header should be easy to do, right?

I have an Excel document (attached) with two Sheets, named A and B. I would like Formulas and Functions to auto populate the header on Sheet B from cells on Sheet A. There will only ever be alphanumeric used; sometimes it is a few words and other times it could be fifteen words.

On Sheet B, the 'Job Name' (seen as Room Renovation) needs to auto populate from Cell C6 on Sheet A and be centered, Bold, Ariel, 14 point font, without other text. The font will remain the same for the entire header. The next line starts with "PO #". There will not be a space followed by the 'Job Number' (seen as 4302). The header seems to be divided into thirds, so I prefer this text to be centered in the middle third header box.

This is a very simplified version of my issue. I have a complex file that has multiple Sheets with links and formulas, so the simplest solution is my preference please. Thank you to everyone who took the time to look at this for me.

5 Replies
best response confirmed by mschonefeld (Copper Contributor)
Solution

@mschonefeld 

This requires VBA. For example in the Worksheet_Activate event:

  • Right-click the sheet tab of sheet B.
  • Select 'View Code' from the context menu.
  • Copy the code listed below into the worksheet module.
  • Switch back to Excel and save the workbook.
  • The header will be updated when you activate sheet B.
Private Sub Worksheet_Activate()
    Me.PageSetup.CenterHeader = _
        "&""Arial""&14&B" & _
        Worksheets("A").Range("H6").Value & vbLf & _
        "PO #" & Worksheets("A").Range("C6").Value & vbLf & vbLf & _
        "PRELIMINARY" & vbLf & vbLf & _
        "COLOR SAMPLE REQUEST"
End Sub

@Hans Vogelaar I want to thank you for saving me years of frustration.

I did have to enable macros, but nothing difficult. Thank you again @Hans Vogelaar 

I would like to be able to add the Date and Time printed in the RightFooter, but keep getting script errors when I alter @hans_Vogelaar's script to include this. Also I would like to include a line just above the print date/time that includes "CC"Field, Job# " and then pulls data from H6.
Any help would be greatly appreciated.
Thanks again.

@mschonefeld 

I'm slightly confused by that, but see the attached version.

Thank you again @hans_Vogelaar
1 best response

Accepted Solutions
best response confirmed by mschonefeld (Copper Contributor)
Solution

@mschonefeld 

This requires VBA. For example in the Worksheet_Activate event:

  • Right-click the sheet tab of sheet B.
  • Select 'View Code' from the context menu.
  • Copy the code listed below into the worksheet module.
  • Switch back to Excel and save the workbook.
  • The header will be updated when you activate sheet B.
Private Sub Worksheet_Activate()
    Me.PageSetup.CenterHeader = _
        "&""Arial""&14&B" & _
        Worksheets("A").Range("H6").Value & vbLf & _
        "PO #" & Worksheets("A").Range("C6").Value & vbLf & vbLf & _
        "PRELIMINARY" & vbLf & vbLf & _
        "COLOR SAMPLE REQUEST"
End Sub

View solution in original post