?
Solved

Excel-how to sort worksheet names alphbetically

Posted on 2002-03-12
2
Medium Priority
?
192 Views
Last Modified: 2007-12-19
Hi, I have an Excel file that has ALOT of worksheets and I have named each on it's tab, but now I want to sort them alphbetically. The only way I know how is to drag the tab and do it manually. Anyone know a quicker way? Thanks! (I have Excel 2000 on a PC)
0
Comment
Question by:aib1996
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 400 total points
ID: 6856843
paste this macro into your worksheet, and let it run.

Public Sub SortSheets()
  Dim lngSheet As Long
  Dim objSheet As Worksheet
 
  Dim lngLoop As Long
  Dim objLoop As Worksheet
   
  For lngSheet = 2 To ThisWorkbook.Sheets.Count
    Set objSheet = ThisWorkbook.Sheets(lngSheet)
    For lngLoop = 1 To lngSheet - 1
      Set objLoop = ThisWorkbook.Sheets(lngLoop)
     
      If objSheet.Name < objLoop.Name Then
        objSheet.Move objLoop
        lngLoop = lngSheet
      End If
    Next
  Next

End Sub

Cheers
0
 

Author Comment

by:aib1996
ID: 6856958
Thank you so much! It worked great.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
MS Outlook undoubtedly is the most widely used email client.Its user-friendliness, cost effectiveness, and availability with Microsoft Office Suite make it the most popular email application.  Its compatibility with Microsoft applications like Exch…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question