Can I place a formula/cell reference in the Header/footer Excel

J

john mcmichael

I would like to place a formula in the Header/footer area so that I can pull
info from one changing cell to the header/footer. Is this possible and if so
how? Thanks in advance to all that reply
 
J

Jason Morin

You can set the header/footer to reference the value of a cell that contains
your formula. For example:

Sub Test()
Dim rFormulaCell As Range
Set rFormulaCell = ActiveSheet.[D1] '<-- change cell
With ActiveSheet
.PageSetup.CenterHeader = rFormulaCell
.PrintOut Copies:=1, Collate:=True
End With
End Sub
 
J

james

It works great. On another note, I tried to put more flexibility by using
named range instead of actual cell reference. However, I got error 438 and
424.

Can it work with named range? Thanks.

James


Jason Morin said:
You can set the header/footer to reference the value of a cell that contains
your formula. For example:

Sub Test()
Dim rFormulaCell As Range
Set rFormulaCell = ActiveSheet.[D1] '<-- change cell
With ActiveSheet
.PageSetup.CenterHeader = rFormulaCell
.PrintOut Copies:=1, Collate:=True
End With
End Sub

---
HTH
Jason
Atlanta, GA


john mcmichael said:
I would like to place a formula in the Header/footer area so that I can pull
info from one changing cell to the header/footer. Is this possible and if so
how? Thanks in advance to all that reply
 
Top