|
||||
These pages are no longer updated and are only available for archive purposes.Click here to visit the pages with updated information. Sort the worksheets in a workbookThe following macro will sort all the worksheets in a workbook in ascending order : Sub SortWorksheets() ' sort worksheets in a workbook in ascending order Dim sCount As Integer, i As Integer, j As Integer Application.ScreenUpdating = False sCount = Worksheets.Count If sCount = 1 Then Exit Sub For i = 1 To sCount - 1 For j = i + 1 To sCount If Worksheets(j).Name < Worksheets(i).Name Then Worksheets(j).Move Before:=Worksheets(i) End If Next j Next i End Sub If you want to sort all the sheets in the workbook, replace worksheets with sheets.
Document last updated 1999-12-20 12:51:17
|
||||
|