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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top