Forum Discussion

Deleted's avatar
Deleted
Aug 21, 2018
Solved

Headers and footers - can I include a cell reference?

Hi! I'm creating a spreadsheet for my users to treat as template. I want the detail that they enter in cell C5 to be included in the footer. I know the standard options let me include a worksheet lab...
  • Haytham Amairah's avatar
    Aug 21, 2018

    Hi,

     

    This is not possible unless you inject the worksheet with some lines of code!

    So please hover the mouse over the worksheet tab, right-click, and select View Code.

     

    Then copy the below code and paste it into the worksheet code module.

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, Range("C5")) Is Nothing Then
            PageSetup.CenterFooter = Range("C5").Value
        End If
    End Sub

     

    Next, save the workbook as .xlsm file extension in order to retain the code in the workbook.

     

    I hope that helps

    Haytham

Resources