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.


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

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!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    shailesh · 3 months ago
    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

  • To post as a guest, your comment is unpublished.
    lucy · 9 months ago
    works well but how can I avoid including the headings (ie row 1?)
    • To post as a guest, your comment is unpublished.
      skyyang · 7 months ago
      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!
      • To post as a guest, your comment is unpublished.
        JULIE BERNARDI · 5 months ago
        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???
  • To post as a guest, your comment is unpublished.
    fabrev · 11 months ago
    worked like a charm for me...thank you!
  • To post as a guest, your comment is unpublished.
    Aun · 1 years ago
    Doesn't work...