Share via


WorksheetBase.Cells Property

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

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntax

'Declaration
Public ReadOnly Property Cells As Range
    Get
public Range Cells { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.Range
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 Sub SetCellFonts()
    With Me.Cells.Font
        .Name = "Verdana"
        .Size = 14
        .Bold = True
    End With
    Me.Range("A1", "A5").Value2 = 123
End Sub
private void SetCellFonts()
{
    this.Cells.Font.Name = "Verdana";
    this.Cells.Font.Size = 14;
    this.Cells.Font.Bold = true;
    this.Range["A1", "A5"].Value2 = 123;
}

.NET Framework Security

See Also

Reference

WorksheetBase Class

Microsoft.Office.Tools.Excel Namespace