Excel: Creating a SUM Formula with a Macro Using Input Range

Last reviewed: November 30, 1994
Article ID: Q27717

SUMMARY

The following information describes how to build a macro step in Microsoft Excel to create a formula in a worksheet cell using a reference that you can input by selection.

To build a macro statement that places a SUM formula in a cell using a cell or range you input, have the macro select the cell. Then include the following macro statement:

   =FORMULA("=SUM("&RELREF(INPUT("select your cell(s): ",8),
   ACTIVE.CELL())&")")

The command macro does the following: selects a cell, asks you to select the range of cells that the SUM function will reference, and enters the complete SUM function into the cell.

Note: This information also applies to Microsoft Excel for Windows versions 2.1, 2.1c, and 3.0, and to Microsoft Excel for OS/2 versions 2.2, 2.21, and 3.0.


KBCategory: kbusage
KBSubcategory:

Additional words: 1.00 1.03 1.04 1.06 2.10 2.10c 2.20 3.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: November 30, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.