» 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
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:
- Real Estate Loopholes: Secrets of Successful Real Estate Investing
- Quantitative Methods in Derivatives Pricing: An Introduction to Computational Finance
- Microsoft Excel VBA Programming for the Absolute Beginner
- The Basics of Finance: Financial Tools for Non Financial Managers
- Financial Statement Analysis with S&P insert card
- Marketing Plans That Work, Targeting Growth and Profitability
No comments have been submitted.

