Include Cell Value in Header (1 Viewer)

akt01

Registered User.
Local time
Today, 20:41
Joined
Jun 19, 2003
Messages
21
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

Smeghead
Local time
Today, 12:41
Joined
Jan 12, 2001
Messages
32,059
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.

Code:
ActiveSheet.PageSetup.CenterHeader = ActiveSheet.Range("A1").Value

and if you want the left header use
.LeftHeader

instead

or the Right

.RightHeader
 

akt01

Registered User.
Local time
Today, 20:41
Joined
Jun 19, 2003
Messages
21
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

Smeghead
Local time
Today, 12:41
Joined
Jan 12, 2001
Messages
32,059
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:

Code:
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).
 

Users who are viewing this thread

Top Bottom