Can you use a formula in headers?

chillyok

New Member
Joined
Nov 15, 2010
Messages
9
I have an workbook with about 20 different sheets. Each sheet has a header that includes a statement date, that will not change as the actual date changes - March statements will always be March. I copy these worksheets monthly and have to manually edit all the headers for the new date.

I thought I could put the statement date "March 2011" in a hidden cell on one worksheet, then use a formula in each of the headers to pull whatever is in that cell, but I only get the actual text of the formula (='Book 1!$!$!'). Any suggestions?:confused:
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
The formula is not correct, but it sounds like the header rows are formatted as Text. Format them in the date format you prefer.
 
Upvote 0
Yes, I realized as soon as I clicked enter, the formula was not correct. It would be a cell reference such as $A$1, in the first sheet.

But I'm actually typing "March 2011". If I type "March 2011" in cell A1, then use a formula in my header =A1, it prints out as "=A1", not March 2011. It's like it doesn't recognize it as a formula in the header. I tried using an actual date, and still got the same results.
 
Upvote 0
The cells are formatted as Text, so you see the formula rather than its results. Change the format.
 
Upvote 0
I'm entering the formula in the header (in page setup), not in a cell in the worksheet. I'm not sure there a way to set a format in the headers/footers in page setup.
 
Upvote 0
Ohhh -- THAT header :rofl::rofl::rofl: Sorry!

You can't enter a formula in the page header, as you've learned. You can enter the current date and time. You'd have to use VBA to copy a cell value.
 
Upvote 0
For example,

Code:
Sub x()
    ActiveSheet.PageSetup.LeftHeader = Range("A1").Text
End Sub
 
Upvote 0
Yea!!! This worked for me. Had to do a little research, because I've never used VBA before, but I got it. Thank you so much!:):)
 
Upvote 0
You're welcome. Sorry for the misunderstanding.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top