Forum Discussion

mschonefeld's avatar
mschonefeld
Copper Contributor
May 19, 2021
Solved

Auto Populate Header Using Another Sheet

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,...
  • HansVogelaar's avatar
    May 19, 2021

    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

Resources