VbaObjectsBeginner

Cells property

Addresses cells by row and column number, which is especially useful in loops.

Review the syntaxStudy the examplesOpen the coding app
Cells(rowIndex, columnIndex)

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

Addresses cells by row and column number, which is especially useful in loops.

Cells is better than Range when the target location is computed at runtime, such as row-by-row imports, report generation, or searching for the last used row. It helps avoid string-building addresses, but it becomes dangerous when used without a worksheet qualifier because it falls back to the active sheet.

Quick reference

Syntax

Cells(rowIndex, columnIndex)

Inputs

Parameters

rowIndexLong · Target row number.
columnIndexLong | String · Target column number or letter.

See it in practice

Examples

1

Loop through input rows

Dim i As Long
For i = 2 To 10
    Cells(i, 3).Value = Cells(i, 1).Value * Cells(i, 2).Value
Next i

Cells shines when row and column positions are dynamic inside a loop.

Debug faster

Common Errors

1

LogicError

Cause: Writing to the active worksheet instead of the intended worksheet.

Fix: Use Worksheets("SheetName").Cells(...) or a worksheet variable.

Runtime support

Compatibility

Excel desktop VBA

Source: Microsoft Learn Office VBA reference

Common questions

Frequently Asked Questions

Addresses cells by row and column number, which is especially useful in loops.

rowIndex: Target row number. columnIndex: Target column number or letter.

LogicError: Use Worksheets("SheetName").Cells(...) or a worksheet variable.