Excel: Selecting Noncontiguous Ranges with a Macro

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: 3.0 adjacent discontinuous nonadjacent

Keywords :
Version :
Platform :
Issue type :


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