Excel VBA Worksheets Object

Basic Description

We mentioned above that Range is a property. But what is it a property of? Well, Range is a property of the Worksheets object. If we wanted to be really specific we should have used the Worksheets object first, then the Range property. Like this:

Worksheets(“Sheet1”).Range(“A1”).Select

Here, the Worksheet comes first. In between round brackets and quote marks you type the name of a worksheet, “Sheet1” in this case. You can also type a number between the round brackets:

Worksheets(1).Range(“A1”).Select

The 1 above refers to the first worksheet in your open spreadsheet.

When you use Range by itself, Excel takes it mean the currently active worksheet, the one you currently have selected and displayed. If you want to refer to a different worksheet, say Sheet 2, you need to refer to it by name:

Worksheets(2).Range(“A1”).Select

Or

Worksheets(“Sheet2”).Range(“A1”).Select

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

code

clearPost Comment