Microsoft KB Archive/37506

-

{| 2.x 3.00 4.00 4.00a 5.00 | 2.20 2.21 3.00 WINDOWS                 | OS/2 kbusage The information in this article applies to:
 * width="100%"|


 * Microsoft Excel for Windows, version 2.x, 3.0, 4.0, 4.0a, 5.0
 * Microsoft Excel for OS/2 versions 2.2, 2.21, 3.0

SUMMARY
When you edit a formula contained in a worksheet from a macro, using the SEND.KEYS function replicates the manual editing steps, as the following example illustrates:

=ACTIVATE(&quot;sheet1.xls&quot;) =SELECT(&quot;r12c2&quot;) =SEND.KEYS(&quot;{F2}editingtext~&quot;) In the SEND.KEYS line, {F2} takes you into edit mode on the formula bar. &quot;editingtext&quot; is the string of keystrokes to press if you are manually editing the formula. The tilde (~ or {ENTER}) terminates the edit mode and enters the formula into the selected cell. Note: The SEND.KEYS text is not sent until a dialog box is displayed, or the macro is finished, so the above cannot be repeated in a macro.

MORE INFORMATION
Examples of SEND.KEYS function editing are as follows:

  Original Formula: =SUM(A1:A10) Editing Command:  =SEND.KEYS(&quot;{F2}*B2~&quot;) Resulting Formula: =SUM(A1:A10)*B2.   Original Formula: =SUM(A1:A10) Editing Command:  =SEND.KEYS(&quot;{F2}{LEFT}{BS}{BS}{BS}C8~&quot;) Resulting Formula: =SUM(A1:C8) 

In the second example, {LEFT} moves the insertion point to the left one character, and {BS} backspaces one character each time, deleting &quot;A10&quot;.