Name
worksheet
.Cells
Synopsis
Returns a Range
object that represents cells on the worksheet. The syntax shows the Cells
property without arguments, which returns all the cells in a worksheet as a Range
object. However, you can also enter the specific range you want to return as if you were using the syntax for a Range
object.
The following code sets the font size to 12 for every cell in the WombatBattingAverages worksheet so the athletes can easily read them:
Worksheets("WombatBattingAverages").Cells.Font.Size = 12
The following code highlights batting averages .300 and over:
Dim rwIndex As Integer For rwIndex = 1 To 3 With Worksheets("WombatBattingAverages").Cells(rwIndex, 2) If .Value >= 0.3 Then .Font.Color = RGB(255, 0, 0) 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.