Vai al contenuto principale

Come ordinare i dati su più fogli di lavoro contemporaneamente?

In Excel, possiamo ordinare i dati in un foglio di lavoro in base a una colonna specifica in modo rapido e semplice, ma hai mai provato a ordinare i dati su più fogli di lavoro? Ordinarli uno per uno richiederà molto tempo, in questo articolo introdurrò un modo semplice per risolverlo.

Ordina i dati su più fogli di lavoro contemporaneamente con il codice VBA


freccia blu freccia destra Ordina i dati su più fogli di lavoro contemporaneamente con il codice VBA

Per ordinare i dati in base a una colonna in tutti i fogli della cartella di lavoro, il seguente codice VBA può aiutarti.

1. Tieni premuto il ALT + F11 chiavi per aprire il Microsoft Visual Basic, Applications Edition finestra.

2. Clic inserire > Modulie incolla il codice seguente nel file Moduli Finestra.

Codice VBA: ordina i dati su più fogli di lavoro contemporaneamente:

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. Quindi premere F5 chiave per eseguire questo codice, tutti i fogli che hanno la stessa formattazione sono stati ordinati in base alla colonna E di ciascun foglio in ordine decrescente contemporaneamente.

Note:: Nel codice sopra, A: F è l'intervallo di dati che desideri ordinare, E è la lettera della colonna su cui si desidera ordinare in base.

I migliori strumenti per la produttività in ufficio

🤖 Assistente AI di Kutools: Rivoluziona l'analisi dei dati basandosi su: Esecuzione intelligente   |  Genera codice  |  Crea formule personalizzate  |  Analizzare i dati e generare grafici  |  Richiama le funzioni di Kutools...
Funzioni popolari: Trova, evidenzia o identifica i duplicati   |  Elimina righe vuote   |  Combina colonne o celle senza perdere dati   |   Round senza formula ...
Super ricerca: VLookup a criteri multipli    VLookup a valori multipli  |   VLookup su più fogli   |   Ricerca fuzzy ....
Elenco a discesa avanzato: Crea rapidamente un elenco a discesa   |  Elenco a discesa dipendente   |  Elenco a discesa a selezione multipla ....
Gestore di colonna: Aggiungi un numero specifico di colonne  |  Sposta colonne  |  Attiva/disattiva lo stato di visibilità delle colonne nascoste  |  Confronta intervalli e colonne ...
Funzionalità in primo piano: Messa a fuoco della griglia   |  Vista di progettazione   |   Grande barra delle formule    Gestore di cartelle di lavoro e fogli   |  Resource Library (Testo automatico)   |  Date picker   |  Combina fogli di lavoro   |  Crittografa/decrittografa le celle    Invia e-mail per elenco   |  Super filtro   |   Filtro speciale (filtro grassetto/corsivo/barrato...) ...
I 15 migliori set di strumenti12 Testo Strumenti (aggiungi testo, Rimuovi personaggi, ...)   |   50+ Grafico Tipi (Diagramma di Gantt, ...)   |   40+ Pratico Formule (Calcola l'età in base al compleanno, ...)   |   19 Inserimento Strumenti (Inserisci il codice QR, Inserisci immagine dal percorso, ...)   |   12 Conversione Strumenti (Numeri in parole, Conversione di valuta, ...)   |   7 Unisci e dividi Strumenti (Combina righe avanzate, Celle divise, ...)   |   ... e altro ancora

Potenzia le tue competenze di Excel con Kutools per Excel e sperimenta l'efficienza come mai prima d'ora. Kutools per Excel offre oltre 300 funzionalità avanzate per aumentare la produttività e risparmiare tempo.  Fai clic qui per ottenere la funzionalità di cui hai più bisogno...

Descrizione


Office Tab porta l'interfaccia a schede in Office e semplifica notevolmente il tuo lavoro

  • Abilita la modifica e la lettura a schede in Word, Excel, PowerPoint, Publisher, Access, Visio e Project.
  • Apri e crea più documenti in nuove schede della stessa finestra, piuttosto che in nuove finestre.
  • Aumenta la produttività del 50% e riduce ogni giorno centinaia di clic del mouse!
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