Article ID: 213618 - Last Review: October 11, 2006 - Revision: 4.2 XL2000: Inserting and Formatting Text in Headers and FootersThis article was previously published under Q213618 On This PageSUMMARY
In Microsoft Excel, you may want to use a header or footer in a worksheet.
The "More Information" section of this article discusses the formatting
codes that you can use to automatically insert and format text in a header
or footer, and it also contains a sample Microsoft Visual Basic for
Applications macro that you can used to add and format text in the header and footer of a worksheet.
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Formatting Codes for Headers and FootersTo use multiple lines in a header, use either of the following methods:
The following tables contain the format codes that you can use in headers and footers.
Codes to format text
--------------------------------------------------------------------
&L Left-aligns the characters that follow.
&C Centers the characters that follow.
&R Right-aligns the characters that follow.
&E Turns double-underline printing on or off.
&X Turns superscript printing on or off.
&Y Turns subscript printing on or off.
&B Turns bold printing on or off.
&I Turns italic printing on or off.
&U Turns underline printing on or off.
&S Turns strikethrough printing on or off.
&"fontname" Prints the characters that follow in the specified
font. Be sure to include the quotation marks around
the font name.
&nn Prints the characters that follow in the specified
font size. Use a two-digit number to specify a size
in points.
Codes to insert specific data ------------------------------------------------------------------- &D Prints the current date &T Prints the current time &F Prints the name of the document &A Prints the name of the workbook tab (the "sheet name") &P Prints the page number &P+number Prints the page number plus number &P-number Prints the page number minus number && Prints a single ampersand &N Prints the total number of pages in the document Sample Visual Basic ProcedureNote that the following code samples assume that the list has a header row starting in cell A1 and data starting in A2. Note also that the "~" indicates a step to be performed on each line of the loop, or at a specified time.To create a sample macro that uses some of the formatting codes:
213633
(http://support.microsoft.com/kb/213633/EN-US/
)
XL2000: How to Display Quotation Marks in Function Results and Macros
REFERENCESFor more information about formatting headers and footers, click Microsoft Excel Help on the
Help menu, type custom header in the Office Assistant or
the Answer Wizard, and then click Search to view the topics
returned.
| Article Translations
|
Back to the top
