Excel: Selecting Noncontiguous Ranges with a Macro

Last reviewed: July 16, 1997
Article ID: Q87324

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, version 3.0
  • Microsoft Excel for the Macintosh, versions 3.0, 4.0, 5.0

SUMMARY

When selecting multiple noncontiguous ranges in a macro, a comma must be used to separate the ranges. To select noncontiguous areas using range names as cell references, the REFTEXT() function must be used.

MORE INFORMATION

To select multiple noncontiguous ranges in a macro using cell references to define a range, each range must be separated by a comma.

Example

=SELECT("r1c1:r5c2,r1c4:r5c5,r1c7:r5c8")

To select multiple noncontiguous ranges in a macro using the defined name solution, use SELECT. Range names must be separated by a comma.

Example

=SELECT((!name1,!name2,!name3))

When selecting areas using defined names, the range names must be enclosed in a REFTEXT() function.

Example

=SELECT(REFTEXT(!name1)&","&REFTEXT(!name2)&","&REFTEXT(!name3))

REFERENCES

"Microsoft Excel Function Reference," version 3.0, pages 192, 209-210

"Microsoft Excel Function Reference," version 4.0, pages 349, 378-379


Additional query words: 5.00 3.00 4.00 3.0 4.0 adjacent discontinuous
nonadjacent


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: July 16, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.