Microsoft KB Archive/87324

{|
 * width="100%"|

Excel: Selecting Noncontiguous Ranges with a Macro

 * }

-

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(&quot;r1c1:r5c2,r1c4:r5c5,r1c7:r5c8&quot;)

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)&&quot;,&quot;&REFTEXT(!name2)&&quot;,&quot;&REFTEXT(!name3))