» Sort the worksheets in a workbook using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Files, Workbook, and Worksheets in VBA
VERSION - All Microsoft Excel Versions
The 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.
Book Store:
Recommended Books:
- Microsoft Excel Version 2002 Step by Step
- Investments + S&P Card + Powerweb + StockTrak discount coupon
- Positioning: The Battle for Your Mind
- Microsoft Office XP Introductory Concepts and Techniques
- How to Read A Financial Report
- Rich Dad's Guide to Investing: What the Rich Invest in, That the Poor and the Middle Class Do Not!
No comments have been submitted.

