XL: Inserting and Formatting Text in Headers and FootersLast reviewed: March 13, 1998Article ID: Q142136 |
The information in this article applies to:
SUMMARYIn 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 (Sub procedure) 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, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/default.asp Formatting Codes for Headers and FootersTo use multiple lines in a header, use either of the following:
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. &O Turns outline printing on or off (Macintosh only). &H Turns shadow printing on or off (Macintosh only). &"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:
Use this code To do this -------------------------------------------------------- &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. Use the following steps to create a sample macro that uses some of the formatting codes:
ARTICLE-ID: Q141578 TITLE : How to Display Quotation Marks in Function Results and Macros REFERENCESIn Microsoft Excel 7.0, for more information about formatting codes, click the Index tab in Microsoft Excel Help, type the following text
headersand then double-click the selected text to go to the "Formatting Codes for Headers and Footers" topic. For more information about Formatting Codes for Headers and Footers, click Answer Wizard on the Help menu and type:
format header footer |
Additional query words: 5.00 5.00a 5.00c 7.00 97 xl97 8.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |