Microsoft KB Archive/27717

{| = Excel: Creating a SUM Formula with a Macro Using Input Range =
 * width="100%"|

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(&quot;=SUM(&quot;&RELREF(INPUT(&quot;select your cell(s): &quot;,8),  ACTIVE.CELL)&&quot;)&quot;) 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.
 * }