Skip to main content

Range.Areas property

Table of contents
  1. Syntax
  2. Remarks
  3. Example

Returns an Areas collection that represents all the ranges in a multiple-area selection. Read-only.

Syntax

expression.Areas

expression A variable that represents a Range object.

Remarks

For a single selection, the Areas property returns a collection that contains one object—the original Range object itself.

For a multiple-area selection, the Areas property returns a collection that contains one object for each selected area.

Example

This example displays a message if the user tries to carry out a command when more than one area is selected. This example must be run from a worksheet.

If Selection.Areas.count > 1 Then
    MsgBox "Cannot do this to a multi-area selection."
End If

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>