Cells property
Addresses cells by row and column number, which is especially useful in loops.
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
See it in practice
Examples
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 iCells shines when row and column positions are dynamic inside a loop.
Debug faster
Common Errors
LogicError
Cause: Writing to the active worksheet instead of the intended worksheet.
Fix: Use Worksheets("SheetName").Cells(...) or a worksheet variable.
Runtime support
Compatibility
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.