In Excel VBA, Range.Item(rowIndex, columnIndex) returns a Range object for the cell at the specified row and column position relative to the top-left cell of the range. For example, Worksheets("Sheet1").Range("B2:D5").Item(2, 3) refers to cell D3—not the worksheet’s second row and third column.
What the Range.Item property does
Item is a property of Excel’s Range object. It gives you a way to address a cell by its position within a range rather than by its A1 address. The result is itself a Range object, even when it represents only one cell. You can then read or change that cell’s value, inspect its address, apply formatting, or use another Range property.
The method is useful when a macro already has a starting range and needs to move through cells using row and column numbers. It can make code easier to reuse: changing the starting range can move the whole calculation or operation without rewriting every cell address.
For a two-dimensional range, use the two-index form:
rowIndexidentifies the row position within the range.columnIndexidentifies the column position within the range.- Both positions start at 1, so
Item(1, 1)is the range’s top-left cell.
Although Item can be omitted in some VBA expressions because it is the Range object’s default member, writing it explicitly helps readers recognize that the code is indexing a range.
How the row and column indexes are calculated
The key detail is that the indexes are relative to the top-left corner of the range. Consider Range("B2:D5"). Its first row is worksheet row 2, its first column is worksheet column B, and it contains four rows and three columns. Therefore, Item(1, 1) is B2, Item(2, 1) is B3, Item(1, 2) is C2, and Item(2, 3) is D3.
This is not the same as using worksheet row and column numbers. The worksheet’s row 2, column 3 is C2; the second row and third column inside B2:D5 is D3. Confusing those two coordinate systems is a common source of off-by-one errors.
A small table makes the relationship clear:
Item(1, 1)→ B2Item(1, 2)→ C2Item(2, 1)→ B3Item(2, 3)→ D3Item(4, 3)→ D5
When the target range begins somewhere other than A1, the same rule applies. The indexes describe positions inside the chosen range, not absolute worksheet coordinates.
A complete VBA example
This macro starts with B2:D5, gets the cell in its second row and third column, prints that cell’s address in the Immediate window, and writes a value to it. The target is D3.
Sub DemonstrateRangeItem()
Dim ws As Worksheet
Dim baseRange As Range
Dim target As Range
' Identify the worksheet and the range to index.
Set ws = ThisWorkbook.Worksheets("Sheet1")
Set baseRange = ws.Range("B2:D5")
' The second row and third column within B2:D5 is D3.
Set target = baseRange.Item(2, 3)
Debug.Print target.Address
target.Value = "Selected by Item"
End Sub
In the Visual Basic Editor, the Immediate window is available from View > Immediate Window. The address printed for this example is $D$3. The assignment changes the cell’s contents, so save a copy of the workbook before running a macro; VBA actions generally cannot be reversed with Ctrl+Z. On Windows, open the editor with Alt+F11. Excel for Mac also supports VBA, though the editor shortcut can depend on the keyboard and function-key settings. Excel for the web does not run VBA macros.
Using the returned Range object
Because Item returns a Range, you can use it in different ways depending on whether you need to read, change, or format the cell. For example, assign the result to an object variable with Set when you want to use it more than once. When you only need a value, you can access the result’s Value or Value2 property directly.
Sub ReadAndFormatCell()
Dim ws As Worksheet
Dim cellToCheck As Range
Set ws = ThisWorkbook.Worksheets("Sheet1")
Set cellToCheck = ws.Range("B2:D5").Item(2, 3)
Debug.Print cellToCheck.Value2
cellToCheck.Font.Bold = True
End Sub
Here, the code reads the current value of D3 and makes its font bold. Value2 is commonly used in VBA when a macro needs the cell’s underlying value without the Currency and Date data-type conversions associated with Value. For ordinary text and numbers, either property may be suitable; choose based on the data and the behavior you need.
You can also use a returned Range in a test or calculation. For example, compare its value with a threshold before changing another cell. Keep the worksheet reference explicit, as in ws.Range(...), so the macro does not accidentally operate on whichever sheet happens to be active.
Range.Item compared with Cells and direct addresses
Cells(row, column) is another common way to get a single cell. On a worksheet, ws.Cells(3, 4) refers to worksheet cell D3 because those numbers are absolute worksheet coordinates. By contrast, baseRange.Item(2, 3) refers to the second row and third column inside baseRange. These expressions can point to the same cell, but their starting points differ.
For range-relative indexing, baseRange.Cells(2, 3) is a familiar alternative and also returns a Range. Using Cells can make the intention especially clear to Excel VBA readers. The explicit form baseRange.Item(2, 3) emphasizes the Item property. In many everyday examples, either is appropriate; the important thing is to keep the coordinate system clear.
A direct address such as ws.Range("D3") is often the clearest choice when the destination is fixed and known. Indexed access becomes more valuable when row or column positions are calculated, or when the base range changes at runtime. For instance, a loop can use a changing row index to inspect each record in a selected block without building a separate address string for every cell.
Indexing beyond the original range
Range indexing is not necessarily limited to the visible dimensions of the range used as the starting point. Excel’s Item behavior can address cells beyond that range, with the indexes still measured from its top-left cell, provided the resulting cell exists on the worksheet. For example, an index larger than the number of rows in a small starting range can refer to a lower worksheet row.
This behavior can be useful when a range is being used as an anchor, but it can also hide mistakes. If a macro is supposed to stay inside a block, check the index against the block’s row and column counts before using it. The Rows.Count and Columns.Count properties can help express that boundary. Also remember that a worksheet has finite row and column limits; an index that would place the result beyond those limits cannot identify a valid worksheet cell.
For a non-contiguous range made from multiple areas, do not assume that one pair of indexes will traverse every area in the order you expect. Work with each area explicitly when the range contains separated blocks. That makes the intended starting point and traversal much easier to verify.
Common mistakes and how to avoid them
- Treating indexes as worksheet coordinates:
Item(2, 3)means the second row and third column relative to the range’s top-left cell. It does not inherently mean worksheet cell C2. - Starting at zero: Excel range positions are one-based. The top-left cell is
Item(1, 1), notItem(0, 0). - Using the wrong worksheet: An unqualified
Rangecan refer to the active sheet. Qualify it with a worksheet variable when the macro must always target a particular sheet. - Forgetting
Setfor an object variable: Assigning a Range object to a declared Range variable requiresSet. Assigning a cell’s value does not. - Assuming the output is a value:
Itemreturns a Range object. Use a property such as.Value,.Value2, or.Addresswhen you need the cell’s contents or address. - Ignoring bounds: If the index is calculated in a loop, verify that it stays in the intended range. A result outside the source block may still be a valid worksheet cell, which means a mistaken index might not immediately raise an error.
When debugging, print the target’s address before changing it. Confirm that the starting range, index values, and resulting address all match your intention. This simple check can reveal a relative-versus-absolute reference problem before a macro edits data.
When Range.Item is a good choice
Use Item when the location is naturally described as a position within a range: for example, “the row selected by this loop and the fourth field in the block.” It is particularly handy when a macro works on a named range or a block whose address may move between worksheets or workbooks.
Prefer a direct A1 reference when a cell is fixed and the address itself makes the code easiest to understand. Prefer worksheet-level Cells(row, column) when the row and column numbers already represent absolute sheet coordinates. Use range-relative Cells(row, column) or Item(row, column) when the indexes should move with the range’s top-left cell.
Whichever form you choose, make the base range explicit and use meaningful variable names. A name such as headerRange or dataBlock conveys more than a generic rng when a procedure has several ranges. Clear coordinates reduce errors and make future changes safer.
Frequently Asked Questions
What does Range.Item return in VBA?
It returns a Range object representing the cell at the requested position relative to the starting range. Read or change the cell’s contents through a property such as Value or Value2.
What does Range(“B2:D5”).Item(2, 3) refer to?
It refers to D3. The first index counts two rows down from the range’s top-left cell B2, and the second counts three columns across from B.
Is Item(1, 1) the first cell in a range?
Yes. With two indexes, Item(1, 1) is the top-left cell of the range. Excel VBA indexes in this form begin at 1, not 0.
Is Range.Item the same as Cells in VBA?
They can be used for similar cell selection, but the reference point matters. Worksheet-level Cells(row, column) uses worksheet coordinates; indexing a range with Item or Cells uses positions relative to that range.
Can Range.Item select a cell outside its starting range?
It can address a cell beyond the range’s dimensions, relative to the range’s top-left cell, if that address is still within the worksheet. Check the indexes explicitly if the macro must remain within the original block.
Can I use VBA Range.Item in Excel for the web?
VBA code is for the Excel desktop application; Excel for the web does not run VBA macros. Open the workbook in desktop Excel to use VBA, or consider Office Scripts for browser-based automation.
Related
- Link Two Data Validation Lists in Excel: Step-by-Step
- How to Insert a Line Across the Page in Microsoft Word
- How to Insert a Leader Line in Microsoft Word
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Access VBA Find Text: Methods, Examples, and FixesTo find text in Access VBA, use a DAO recordset’s FindFirst method with a criterion such as [LastName]…
- VBA Range Is Empty? How to Check Cells CorrectlyTo check whether a VBA range contains no entered values or formulas, use Application.CountA(target) = 0. First make…
- Excel Macro VBA Tutorial: Write and Run a First MacroAn Excel macro is a set of instructions that automates actions in a workbook, and VBA (Visual Basic…
- Excel Number to Words: Formula, VBA, and How to Use ItExcel has no built-in English worksheet formula that converts an ordinary number into words. In Microsoft 365 for…
- Excel VBA Activate Sheet: Syntax, Examples, and FixesTo activate a worksheet with VBA, reference it by name and call its Activate method: ThisWorkbook.Worksheets("Summary").Activate. The sheet…
- Excel VBA Option Explicit: What It Does and How to Use ItOption Explicit is a VBA module setting that requires you to declare variables before using them. Put it…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.