Making a Multiple Selection from a Macro in Excel

ID: Q76692


The information in this article applies to:
  • Microsoft Excel for Windows, versions 3.0, 4.0, 4.0a, 5.0
  • Microsoft Excel for OS/2, versions 2.2, 3.0
  • Microsoft Excel for the Macintosh, versions 3.0, 4.0, 5.0


SUMMARY

To select multiple ranges on a spreadsheet from a Microsoft Excel macro, it is necessary to separate the ranges you want to select with a comma and either enclose them with a set of parentheses within the SELECT statement, or to enclose the reference in quotation marks.


MORE INFORMATION

The SELECT statement takes two arguments. The first argument is the cell or range of cells you want to select. The second argument is the cell in the range you want to make the active cell.

When using the SELECT statement in a macro to select multiple ranges, it is necessary to enclose the set of ranges in parentheses. Otherwise, the second range will be seen as the second argument to the SELECT statement, resulting in a macro error.

Example

To perform a multiple selection in a Microsoft Excel macro to select ranges A1:A5 and C1:C5 on the active worksheet, use the following SELECT statement in your macro:

   =SELECT((!A1:A5,!C1:C5)) 
To perform the same action using quoted references, use:

   =SELECT("R1C1:R5C1,R1C3:R5C3") 


REFERENCES

"Function Reference," version 4.0, pages 378-381

"Microsoft Excel Function Reference," version 3.0, pages 209-212

"Microsoft Excel Functions and Macros," for Windows version 2.1, pages 348-349

"Microsoft Excel for OS/2 Functions and Macros," version 2.2, pages 354-355

Additional query words: 2.0 2.00 2.01 2.1 2.10 2.2 2.20 2.21 3.0 \* 5x Tech_Review: edb MacXL5 briance

Keywords :
Version : MACINTOSH:3.0,4.0,5.0; WINDOWS:3.0,4.0,4.0a,5.0; :2.2,3.0
Platform : MACINTOSH WINDOWS
Issue type :


Last Reviewed: October 25, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.