XL97: Print Area with Merged Cells May Be Set Incorrectly

Last reviewed: January 9, 1998
Article ID: Q170683
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

When you set a print area on a worksheet in Microsoft Excel 97, the print area may not be set correctly if the worksheet contains any merged cells. Specifically, only part of a merged cell may be included in the print area. As a result, when you print the worksheet, the output may not contain all of the information.

CAUSE

This problem may occur if you use either of the following methods to set the print area:

  • While a range of cells is selected, you type "print_area" (without the quotation marks) in the Name box and press ENTER.

        -or-
    
  • In a Visual Basic for Applications macro, you set the print area by using a line of code similar to the following:

          ActiveSheet.PageSetup.PrintArea = Range("B2").Address
    

    In this example, B2 is the address of a cell that is part of a merged cell.

WORKAROUND

To prevent this problem from occurring, use any of the following methods to set a print area:

  • Instead of typing "print_area" (without the quotation marks) in the Name box, point to Print Area on the File menu, and click Set Print Area.

        -or-
    
  • If you are using a macro to set the print area, modify the code so that it uses the Selection property instead of the Range property. For example, if your code currently looks like this

          ActiveSheet.PageSetup.PrintArea = Range("B2").Address
    

    change it to the following:

          Range("B2").Select
          ActiveSheet.PageSetup.PrintArea = Selection.Address
    

        -or-
    
  • Make sure that the range referred to by the macro includes all of the cells that have been merged, for example:

          ActiveSheet.PageSetup.PrintArea = Range("B2:F20").Address
    

Using any of these methods ensures that the print area is set correctly.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The following steps demonstrate the problem described in this article:

  1. In Microsoft Excel 97, create a new workbook.

  2. In Sheet1 of the new workbook, select the range B2:F20. On the Formatting toolbar, click the Merge And Center tool.

  3. Select the merged cell.

  4. In the Name box, type "print_area" (without the quotation marks) and press ENTER.

Note that the dotted line that borders the print area surrounds only the original cell B2, not the entire merged cell. If you type a value in cell B2, and then view the worksheet in print preview, nothing is printed because the print area covers includes only the original cell B2.

To properly set the print area, select the merged cell. Then, point to Print Area on the File menu, and click Set Print Area. Click OK to set the print area. The print area includes the entire merged cell.

If you use a macro to set the print area, make sure that the macro uses the Selection property rather than the Range property. Or, make sure that the Range property refers to all of the cells that you merged.


Additional query words: XL97
Keywords : kbprint
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 9, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.