akt01
03-15-2011, 11:35 AM
I am using Excel 2003. I would like to include a cell value in my Header.
For example, cell A1 says "John Smith," so I want "John Smith" in the Header.
Is this possible.
P.S. I searched online and found VBA solutions. I am not comfortable with VBA. But it seems this is simple, it should not require VBA. Help?
boblarson
03-15-2011, 11:46 AM
P.S. I searched online and found VBA solutions. I am not comfortable with VBA. But it seems this is simple, it should not require VBA. Help?
I'm afraid it does.
ActiveSheet.PageSetup.CenterHeader = ActiveSheet.Range("A1").Value
and if you want the left header use
.LeftHeader
instead
or the Right
.RightHeader
akt01
03-15-2011, 04:05 PM
Bob - thanks for the reply. I was afraid of that. Can you help me ... where do I put this code. I can launch the VBA Editor, but I don't know what to do next.
Thanks again
boblarson
03-16-2011, 07:40 AM
Well the first thing to determine is when will you want this to be updated? If you just want it to be updated when the workbook is saved you can put it in the BeforeSave event on the ThisWorkbook object. To do that you would go to the VBA window (in 2003 and earlier it is TOOLS > MACRO > VISUAL BASIC EDITOR) and then double click on the item named ThisWorkbook in the project explorer (the project explorer is usually open on the top left of the screen and is like a tree view of the workbook objects. If it isn't open you can go to VIEW > PROJECT EXPLORER from the VBA Window).
Once the ThisWorkbook has been double clicked then you will probably get something like this that opens up:
Private Sub Workbook_Open()
End Sub
You don't want that one so you select the BeforeSave event from the dropdown at the top right of the VBA window. It would be displaying OPEN before you make the selection (and the dropdown to the left would say WORKBOOK).