Skip to content

Latest commit

 

History

History
57 lines (36 loc) · 1.41 KB

Excel.Workbook.Worksheets.md

File metadata and controls

57 lines (36 loc) · 1.41 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Workbook.Worksheets property (Excel)
vbaxl10.chm199166
vbaxl10.chm199166
Excel.Workbook.Worksheets
8b7d660d-ca49-0bd0-dc57-64defa47bd5e
05/29/2019
medium

Workbook.Worksheets property (Excel)

Returns a Worksheets collection that represents all the worksheets in the specified workbook. Read-only Worksheets object.

Syntax

expression.Worksheets

expression A variable that represents a Workbook object.

Remarks

Using this property without an object qualifier returns all the worksheets in the active workbook.

This property doesn't return macro sheets; use the Excel4MacroSheets property or the Excel4IntlMacroSheets property to return those sheets.

Example

This example displays the value in cell A1 on Sheet1 in the active workbook.

MsgBox Worksheets("Sheet1").Range("A1").Value

This example displays the name of each worksheet in the active workbook.

For Each ws In Worksheets 
 MsgBox ws.Name 
Next ws

This example adds a new worksheet to the active workbook and then sets the name of the worksheet.

Set newSheet = Worksheets.Add 
newSheet.Name = "current Budget"

[!includeSupport and feedback]