Microsoft Knowledge Base

XL: Error in Macro that Creates Chart from Nonadjacent Cells

Last reviewed: September 13, 1996
Article ID: Q119260
The information in this article applies to:
  • Microsoft Excel for Windows, versions 4.0, 4.0a, 5.0, 5.0c
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a
  • Microsoft Excel for the Macintosh, versions 4.0, 5.0

SYMPTOMS

In Microsoft Excel, if you turn on the macro recorder, and you use the Chart Wizard to create a chart, and the source data for the chart is from a nonadjacent selection of cells, you will receive the following error message when you run the macro:

   Error in formula

CAUSE

This behavior occurs only when you record a macro using the MS Excel 4.0 macro language. The problem occurs because the complete reference is recorded only for the first selection of cells. The additional recorded references contain the cell reference only, without the workbook and worksheet.

For example, if you select the range A1:A3 and B2:B4 on Sheet1 in BOOK1.XLS to create the chart, the references are recorded as [BOOK1.XLS]!Sheet1.xls!R1C1:R3C1, and R2C3:R4C3.

Note that in Microsoft Excel versions 5.x and 7.0, this problem occurs when you use the Chart Wizard to create a chart on its own sheet, or an embedded chart on a worksheet other than the worksheet that contains the chart data.

WORKAROUNDS

To avoid receiving a macro error when you record a macro that creates a chart from nonadjacent cells, do either of the following:

  • In Microsoft Excel versions 5.x and 7.0, record the macro in the Visual Basic macro language.

    -or-

  • Edit the recorded MS Excel 4.0 macro and add the workbook and worksheet name to the cell references that are incomplete.


KBCategory: kbprg
KBSubcategory:

Additional reference words: 4.00 4.00a 5.00 err msg 5.00c 7.00




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: September 13, 1996
©1997 Microsoft Corporation. All rights reserved. Legal Notices.