How to sort data on multiple worksheets at once?
In Excel, we can sort data in a worksheet based on a specific column quickly and easily, but, have you ever tried to sort the data across multiple worksheet? To sort them one by one will be time-consuming, this article, I will introduce an easy way for solving it.
Sort data on multiple worksheets at once with VBA code
Sort data on multiple worksheets at once with VBA code
To sort data based on one column in all sheets of your workbook, the following VBA code can help you.
1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Sort data on multiple worksheets at once:
Sub SortAllSheets()
'Updateby Extendoffice
Dim WS As Worksheet
ActiveSheet.Range("a1:f1").Select
Selection.Copy
On Error Resume Next
Application.ScreenUpdating = False
For Each WS In Worksheets
WS.Columns("A:F").Sort Key1:=WS.Columns("E"), Order1:=xlDescending
Next WS
ActiveSheet.Range("A1").PasteSpecial Paste:=xlPasteAll
Application.ScreenUpdating = True
End Sub
3. Then press F5 key to run this code, all sheets which have the same formatting have been sorted based on column E of each sheet in descending order at once.
Note: In the above code, A:F is the data range that you want to sort, E is the column letter which you want to sort based on.
Unlock Excel Magic with Kutools AI
- Smart Execution: Perform cell operations, analyze data, and create charts—all driven by simple commands.
- Custom Formulas: Generate tailored formulas to streamline your workflows.
- VBA Coding: Write and implement VBA code effortlessly.
- Formula Interpretation: Understand complex formulas with ease.
- Text Translation: Break language barriers within your spreadsheets.
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!