Solved

Excel-how to sort worksheet names alphbetically

Posted on 2002-03-12
2
186 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 100 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction It seems that at least a couple of times per month, I answer a question that requires automating Outlook from another Microsoft Office application, usually (although not always) to send one or more email messages.  For example: …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

840 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