Name

range.Cells([RowIndex], [ColumnIndex])

Synopsis

Returns a Range object representing all the cells in the specified range or a subset indexed by row number and/or column number.

Argument

Settings

RowIndex

The row number of the cells to return

ColumnIndex

The column number of the cells to return

The following code changes the font to bold type for cells in the specified range with batting averages over .300:

Dim r As Range
Dim rwIndex As Integer
 
Set r = Worksheets("WombatBattingAverages").Range("B1:B3")
 
For rwIndex = 1 To 3
    With r.Cells(rwIndex)
         If .Value >= 0.3 Then
              .Font.Bold = True
         End If
    End With
Next rwIndex

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.