Sheets Property

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.  

Sheets property as it applies to the Spreadsheet object.

Returns a Sheets collection that represents all the sheets in the active workbook.

expression.Sheets

expression   Required. An expression that returns a Spreadsheet object.

Sheets property as it applies to the Workbook object.

Returns a Sheets collection that represents all the sheets in the specified workbook.

expression.Sheets

expression   Required. An expression that returns a Workbook object.

Example

As it applies to the Workbook object.

This example sorts the worksheets in the active workbook of Spreadsheet1 in ascending order.

  Sub Sort_Sheets()
   Dim i
   Dim j
   Dim iSheetCount

   iSheetCount = Spreadsheet1.ActiveWorkbook.Sheets.Count

   For i = 1 To iSheetCount
      For j = 1 To iSheetCount - 1
         If UCase(Spreadsheet1.ActiveWorkbook.Sheets(j).Name) > _
            UCase(Spreadsheet1.ActiveWorkbook.Sheets(j + 1).Name) Then

             Spreadsheet1.ActiveWorkbook.Sheets(j).Move , _
                Spreadsheet1.ActiveWorkbook.Sheets(j + 1)
         End If
      Next
   Next
End Sub