LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Can I create a custom header that depends on cell contents?

Alt + F11 to open Visual Basic Editor.

CTRL + r to open Project Explorer.

Select your workbook/project and Right-clickInsertModule.

Paste the code in there.

Alt + q to return to the Excel and ToolsMacroMacros to run the macro.

Or you could place the code into Thisworkbook module as a Before_Print event to
run whenever you printed the activesheet.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet
.PageSetup.CenterFooter = "To: " & .Range("A1").Value & vbLf & _
"Attention: " & .Range("A2").Value & vbLf & _
"Phone Number: " & .Range("A3").Value
End With
End Sub

To use that method, right-click on the Excel Icon left of "File" and select
"View Code".

Copy/paste the Before_Print code into that module.


Gord

On Mon, 2 Jun 2008 20:27:01 -0700, Fred wrote:

Do I create via Tools - Macro - Visual Basic Editor?

If so, once I've created the procedure, how do I invoke?

Thanks for the quick reply.

Fred

"Gord Dibben" wrote:

Fred

Assumes 3 cells have the data.

If only one cell, do the editing.

Sub CellInFooter()
With ActiveSheet
.PageSetup.CenterFooter = "To: " & .Range("A1").Value & vbLf & _
"Attention: " & .Range("A2").Value & vbLf & _
"Phone Number: " & .Range("A3").Value
End With
End Sub


Gord Dibben MS Excel MVP

On Mon, 2 Jun 2008 15:34:01 -0700, Fred wrote:

I am attempting to populate the center section of a custom header with data
which is dependent upon reference to data in a worksheet cell. In this case,
I am creating a custom order form which is addressed to a different supplier
and will have different ("To:", "Attention:", and phone number information).




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Header - poss to link to contents of cell? Smudge Excel Discussion (Misc queries) 7 October 31st 07 04:05 PM
Macro to create a custom header/footer... jgbadingerjr Excel Discussion (Misc queries) 0 March 13th 07 12:27 AM
can I use a cell's contents as part of a custom header? NHVP Treasurer Excel Discussion (Misc queries) 1 February 12th 06 03:28 AM
excel - insert cell contents in a custom header / footer b Excel Discussion (Misc queries) 0 August 25th 05 06:51 PM
contents of 1 combo box depends on choice of another Basheed Bazi Excel Worksheet Functions 2 June 24th 05 09:53 PM


All times are GMT +1. The time now is 05:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"