Share via


WorksheetBase.Cells Property

Definition

Gets a Range object that represents all the cells on the worksheet (not just the cells that are currently in use).

public:
 property Microsoft::Office::Interop::Excel::Range ^ Cells { Microsoft::Office::Interop::Excel::Range ^ get(); };
public Microsoft.Office.Interop.Excel.Range Cells { get; }
member this.Cells : Microsoft.Office.Interop.Excel.Range
Public ReadOnly Property Cells As Range

Property Value

A Range object that represents all the cells on the worksheet (not just the cells that are currently in use).

Remarks

The following code example uses the Cells property to set the name, size, and boldness of the font in every cell on the worksheet.

This example is for a document-level customization.

private void SetCellFonts()
{
    this.Cells.Font.Name = "Verdana";
    this.Cells.Font.Size = 14;
    this.Cells.Font.Bold = true;
    this.Range["A1", "A5"].Value2 = 123;
}
Private Sub SetCellFonts()
    With Me.Cells.Font
        .Name = "Verdana"
        .Size = 14
        .Bold = True
    End With
    Me.Range("A1", "A5").Value2 = 123
End Sub

Applies to