Sorting Excel Worksheets in Alphabetical Order
Suppose you are working on an Excel Workbook having numerous worksheets (For example an excel workbook having multiple worksheets named as per names of all the employees).
Now, you want to arrange all those worksheets in Alphabetical Order.
Doing this manually can take a lot of time. But this can be done with just a few clicks if you use Excel VBA.
The steps are given below.
- Open the worksheet and press Alt + F11 to open the Visual Basic Editor.
2. Go to Insert menu and click ‘Module’. A new module will be inserted. Here you can enter the VBA code.
3. Copy the following code and paste it in the code box.
Dim numberOfSheets As Integer
Dim sheetPosition As Integer
Dim I As Integer
numberOfSheets = ActiveWorkbook.Worksheets.Count
sheetPosition = numberOfSheets
If sheetPosition = 1 Then Exit Do
For I = 1 To sheetPosition – 1
If Sheets(I).Name > Sheets(I + 1).Name Then
Sheets(I + 1).Move before:=Sheets(I)
sheetPosition = sheetPosition – 1
4. Press F5 to run the macro. All the sheets will be arranged in alphabetical order.
Cool, isn’t it? Hope you found this short post useful. If you want to get our posts in your email, please subscribe to our newsletter by filling the form below (and also get my course worth $25 for free).
GET MY EXCEL GUIDE FOR FREE
COMPLETE EXCEL FUNCTIONS AND SHORTCUTS GUIDE
Subscribe to our newsletter and get my Complete Excel Functions and Shortcuts Guide for FREE!
Thank you for subscribing.
Something went wrong.
See you soon with another such useful article. Happy Excelling!!