DIAdem Help

Collection: Worksheets

  • Updated2024-09-12
  • 1 minute(s) read

Collection: Worksheets

Collection of Excel worksheets.

The following example creates an Excel workbook and returns the number of worksheets.

VBScriptPython

 

Dim oMyWorkbook, oMyWorksheets
Set oMyWorkbook = CreateExcelWorkbook()
Set oMyWorksheets = oMyWorkbook.Worksheets
Call MsgBox(oMyWorksheets.Count)

The following example creates an Excel workbook, fills the first worksheet with random values, and highlights the cells containing the value 47 with a red background:

VBScriptPython

 

Dim iRow, jCol, oMyWorkbook, oMySheet, oMyCell
Set oMyWorkbook = CreateExcelWorkbook()
Set oMySheet = oMyWorkbook.Worksheets(1)
For iRow = 1 to 1000
  For jCol = 1 to 20
    Set oMyCell = oMySheet.Cells(iRow, jCol)
    oMyCell.Value = Round(Random(100))
    If oMyCell.Value = 47 Then oMyCell.Interior.Color = RGB(255, 0, 0)
  Next
Next
Call oMyWorkbook.SaveAs(DataWritePath & "Test.xlsx")

Properties

Count

Methods

Add | Exists | Item | Remove | RemoveAll

Returned From

Workbook.Worksheets