Download free Excel Macro : Sort Worksheets
Macros are one of the most powerful features in Excel. They are small programs that can automate tasks and save you a lot of time.
If you are not familiar with macros, they can seem a bit daunting. But once you learn how to use them, you will wonder how you ever managed without them!
In this article, we will show you how to use the Macro "Sort Worksheets" in Excel. We will also provide some examples of how macros can be used to automate tasks.
How to use Macros in Excel?
Macros are written in a programming language called Visual Basic for Applications (VBA). VBA is a simple language that is easy to learn.
You do not need to be a programmer to use macros. However, if you are familiar with programming, you can use VBA to create more complex macros.
There are two ways to use macros in Excel:
1. Use a macro that is already written.
2. Write your own macro.
For both methods check out those articles to know how to use macros in Excel:
To create a macro in Excel, open the Visual Basic Editor (VBE) by pressing Alt+F11 on your keyboard.
In the VBE, select Insert > Module. This will insert a new blank module into the VBE.
In the new module, paste the code below.
For example, the following code will create a macro that will Sort Worksheets:
Sub SortWorksheets() Dim i As Integer Dim j As Integer Dim iAnswer As VbMsgBoxResult iAnswer = MsgBox("Sort Sheets in Ascending Order?" & Chr(10) _ & "Clicking No will sort in Descending Order", _ vbYesNoCancel + vbQuestion + vbDefaultButton1, "Sort Worksheets") For i = 1 To Sheets.Count For j = 1 To Sheets.Count - 1 If iAnswer = vbYes Then If UCase$(Sheets(j).Name) > UCase$(Sheets(j + 1).Name) Then Sheets(j).Move After:=Sheets(j + 1) End If ElseIf iAnswer = vbNo Then If UCase$(Sheets(j).Name) < UCase$(Sheets(j + 1).Name) Then Sheets(j).Move After:=Sheets(j + 1) End If End If Next j Next i End Sub
To run the macro, press the Run button in the toolbar (or press F5 on your keyboard).
About Sort Worksheets Excel Macro
If you are looking for a way to sort your worksheets in Excel, then you may want to consider using a sort worksheets macro. This macro can be found online and is easy to use. Simply download the macro and open it in Excel. Then, enter the names of the worksheets you want to sort into the first column. In the second column, enter the order you want the worksheets to be sorted in. Finally, click the "Sort" button to sort the worksheets.