The information in this article applies to:
SUMMARYIn Microsoft Excel, if you have a macro that prints a range of cells on your worksheet, it may not print all of your data if you have inserted rows within the range specified in your macro. However, if rather than hard-coding a specific range of cells to print, you instead use a print area that refers to a defined name on your worksheet, you can create a print macro that automatically adjusts to any additional rows you insert into the range. 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 professionals 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/overview/overview.asp To follow the example provided in this article, enter any text information into the cell range A1:D5 on Sheet1 of a new workbook. If you record a macro that selects the range of cells, sets the print area, and then prints the worksheet, you create a macro similar to the following:
The problem with this macro is that if you insert one or more rows within this range of cells, and then rerun the recorded macro, it still prints only the range specified in the macro. The macro does not print any rows that were moved down because of the row or rows that you inserted. In order to have your macro automatically adjust when you insert or delete rows within the range you want to print, create a defined name for the range, and then use the defined name in your macro. For this example, you would do the following:
REFERENCESFor more information about defining a name for a range of cells, click Microsoft Excel Help on the
Help menu, type Name cells in a workbook in the Office Assistant or
the Answer Wizard, and then click Search to view the topic. Additional query words: XL2000
Keywords : kbprg kbdta kbdtacode PgmHowto KbVBA |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |