Home
FREE DOWNLOADS
VBA Tutorials
VBA Code Samples
VBA Code - Excel
VBA for Beginners
Save Time on PC
SaveTimeWebsite
Save Time News
Save Time Blog
SaveTime SiteMap
Customer Service
Gibberish

Subscribe To
This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Add to Newsgator
Subscribe with Bloglines

VBA Excel Range

In VBA Excel Range can be used in three basic ways.

The first way is to directly refer to the Range. For example...

Range("B5:E8").Select

or

Range("B5:E8").Value

or whatever Method or Property you choose.

When another Worksheet is active, you qualify the range with the Worksheet object. Either by Name...

Sheets("Sheet3").Range("B5:E8").Border

or by its index...

Sheets(1).Range("B5:E8").Border

And when another Workbook is active you qualify the Sheet with the Workbook. Either by Name...

Workbooks("MyWorkbookName").Sheets("Sheet3").Range("B5:E8").Value

or by its index...

Workbooks(2).Sheets("Sheet3").Range("B5:E8").Value

Using the Cells Method

Cells(2,5).Select

Would select the Cell or Range("B5")

You can also specify a range of more than one Cell...

Range(Cells(2,5), Cells(5,8))

Qualify the Range where needed as above.

Using the Cells Method is obviously much easier to use while looping though rows and columns of cells, since you can use the counters directly without converting the column to a letter(s) and the row to a string to look like "B5", for example.

Using the Offset Method

This is like using the Cells Method except that you choose which Cell your row and column numbers are Offsetting from instead of an imaginary Cell(0,0) in the upper left corner.

Range("E5").Offset(1,1).Value

This would reference Cell "F6".

Enter your E-mail Address
First Name (optional)
Then

Don't worry -- your e-mail address is totally secure.
I promise to use it only to send you Your Save Time News.
Google

Return from VBA Excel Range to VBA Code Samples

Return to our Homepage



footer for vba excel range page