sort all sheets

bigmac1

New Member
Joined
Oct 9, 2016
Messages
17
hello all, can you help please , I want to sort all my data on my sheets , if I put a filter on row 5 for example and sort by a-z on the "totals" sheet (10 columns on each sheet) this works ok but I want to get it to do the same on all sheets, and not have to open each sheet and do a sort a-z (all sheets exactly the same setup ):confused:
 
Last edited:

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try this

Code:
Sub Macro1()
  Dim sh As Worksheet
  For Each sh In Sheets
    sh.Range("A5:Z" & sh.Range("A" & Rows.Count).End(xlUp).Row).Sort key1:=sh.Range("A5"), order1:=xlAscending, Header:=xlYes
  Next
End Sub
 
Upvote 0
hello DanteAmor thank you for your reply, I have tried this code and it filters the A column on the first sheet but it reverses the sort on column B to P , so it shows column A sorted low to high [A6 = 1, A7 = 2 A7 = 3 etc] but the corresponding values in all other rows B to P are now in the bottom of the rows, so the value that should show in B6 is now shown in row B110, also all the other sheets are showing all results at the bottom rows not the top , any ides please
 
Upvote 0
The macro sorts all rows in columns A through Z based on column A.
What do you need?
You could give examples of what you have and what you expect from the result.
 
Upvote 0
The macro sorts all rows in columns A through Z based on column A.
What do you need?
You could give examples of what you have and what you expect from the result.
hi I cannot attach a sheet to this thread , can I send you a link to a dropbox link?
 
Upvote 0
hi I cannot attach a sheet to this thread , can I send you a link to a dropbox link?

Yes please.
If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0
Then you just need to order the "totals" sheet.
Try this

Code:
Sub Macro1()
  Dim sh As Worksheet
  Set sh = Sheets("Totals")
  sh.Range("A5:P" & sh.Range("A" & Rows.Count).End(xlUp).Row).Sort key1:=sh.Range("A5"), order1:=xlAscending, Header:=xlYes
End Sub
 
Upvote 0
Then you just need to order the "totals" sheet.
Try this

Code:
Sub Macro1()
  Dim sh As Worksheet
  Set sh = Sheets("Totals")
  sh.Range("A5:P" & sh.Range("A" & Rows.Count).End(xlUp).Row).Sort key1:=sh.Range("A5"), order1:=xlAscending, Header:=xlYes
End Sub
I have tried this and it works on "totals" sheet, but it does not move the data in all other sheets to the correct rows, if I put a new welder ID in the totals sheet [P123]and open sheet template 2 and place data on the P123 row and do a sort as you have shown then the data in template 2 stays in the same row (the P123 moves to its new position but not the data for that welder.
 
Upvote 0
But in the "Template (2)" sheet In column A you have the formula =totals!A11
But in column B there are no formulas.
Then it is not to sort the data. I believe that you must regenerate all the data on the sheets based on the data in column A.
Or, put formulas on the sheets (eg, vlookup)
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,967
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top