Method: Remove for Worksheets
- Updated2024-09-12
- 1 minute(s) read
Methods > Method: Remove for Worksheets
Method: Remove for Worksheets
Deletes a worksheet in an Excel workbook.
Object.Remove(NameOrIndex)
| Object | Worksheets Object with this method |
| NameOrIndex | Variant Specifies the name or index of the worksheet. |
The following example creates an Excel workbook, checks whether the Data worksheet exists, and deletes it. Refer to the help page Worksheets for detailed examples:
| VBScript | Python |
Dim oMyWorkbook, oMyWorkSheet Set oMyWorkbook = CreateExcelWorkbook() If oMyWorkbook.Worksheets.Exists("Data") Then Call oMyWorkbook.Worksheets.Remove("Data") End If