VbaObjectsBeginner

Range object

Represents one or more worksheet cells and is the core object for Excel automation.

Review the syntaxStudy the examplesOpen the coding app
Range("A1")
Range("A1:C10")

This static page keeps the syntax and examples indexed for search, while the coding app handles interactive exploration and saved references.

What it does

Overview

Represents one or more worksheet cells and is the core object for Excel automation.

Range is the center of most Excel VBA macros. It lets you read values, write formulas, format cells, copy blocks, and chain object model actions. It is the right abstraction when you know the address or named range you want; Cells is often better when you need row-column indexing inside loops.

Quick reference

Syntax

Range("A1")
Range("A1:C10")

See it in practice

Examples

1

Write a formula block

Range("C2:C10").Formula = "=A2*B2"
Range("C2:C10").NumberFormat = "£#,##0.00"

Range works well when the target area is already known and can be expressed as an address.

Debug faster

Common Errors

1

Run-time error 1004

Cause: Using an invalid range address or assuming the active worksheet is the intended sheet.

Fix: Qualify the range with Worksheet references when workbook context matters.

Runtime support

Compatibility

Excel desktop VBA

Source: Microsoft Learn Office VBA reference

Common questions

Frequently Asked Questions

Represents one or more worksheet cells and is the core object for Excel automation.

Run-time error 1004: Qualify the range with Worksheet references when workbook context matters.