Skip to main content

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


arrow blue right bubble 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.

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions…
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

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...

Description


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!
Comments (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
This didn't seem to work for me. I have a workbook with 12 sheets ordered by months of the year each sheet containing corresponding data regarding companies products etc. My objective is to sort and filter the all the sheets in the workbook. I would like to have one sheet that would act as the parent sheet (e.g. first month of the year), which I would perform a filter or sort function on (e.g. A -> Z sort) and automatically have the other sheets follow the same sort or filter. For example, when using the sheet labeled "January" if for example I choose column "D" which includes the days in the month which I want in "ascending" order - when actualizing the A -> Z sort on the "January" sheet, I want this to effect the rest of all the sheets in the sequence (Feb-Dec) with all days of the month sorted A -> Z. Any change made on the "January" sheet as it relates to sorting and filtering, should effect the balance of the sheets in the workbook.
This comment was minimized by the moderator on the site
Can you run this without including all sheets? I.e. leave some sheets out of the macro?
This comment was minimized by the moderator on the site
i want to split the data in multiple work books and then add the value in one of the column..

i have prepared the code to split the data in workbooks.. but need help on adding the total in one of the column
This comment was minimized by the moderator on the site
works well but how can I avoid including the headings (ie row 1?)
This comment was minimized by the moderator on the site
Hello, Lucy,
To sort all sheets exclude the header row, please apply the below vba code:(Note: please change the cell references to your need)

Sub SortAllSheets()
'Updateby Extendoffice
Dim WS As Worksheet
Dim xIntR As Integer
ActiveSheet.Range("A1:F1").Select
On Error Resume Next
Application.ScreenUpdating = False
For Each WS In Worksheets
xIntR = Intersect(WS.UsedRange, WS.Range("A:F")).Rows.Count
WS.Range("A2:F" & xIntR).Sort Key1:=WS.Range("A2:A" & xIntR), Order1:=xlDescending
Next WS
Application.ScreenUpdating = True
End Sub

Please try, hope it can help you!
This comment was minimized by the moderator on the site
Hey this is great thank you so much for this! My only issue with this code is that it does not execute on my first sheet. It does execute on my remaining sheets. HOw would I get this to execute on all of the sheets? It's as if the code skips over the first sheet. Any help would be much appreciated :)
This comment was minimized by the moderator on the site
Very usefull code Thanks
This comment was minimized by the moderator on the site
In the hope that you see this...! This works wonderfully - but it includes cells with a formula but no data, creating gaps in the tabs and messing up the data on the rows. I need to keep those cells in my tabs as they look up names added to the 'master tab' I want it to only sort cells with an actual name - a quick fix???
This comment was minimized by the moderator on the site
worked like a charm for me...thank you!
This comment was minimized by the moderator on the site
Doesn't work...
This comment was minimized by the moderator on the site
How can I make this work for multiple columns. I am trying to sort some by the K column and some by the M column and I know the exact sheet numbers. My M column (when I use the above code) is only being sorted by the K, not by M, so therefore it is not working. 
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
Rate this post:
0   Characters
Suggested Locations