VBA Excel: ordinare i fogli
- 11 Agosto 2023
- Pubblicato da: Marco Lauricella
- Categoria: Blog
Nessun commento

Letto: 20
Autore: Andrea Pacchiarotti
Per ordinare i fogli in senso crescente in base al nome è possibile utilizzare la routine seguente che, a seconda delle necessità, può essere eseguita:
- da un pulsante posto:
- sulla barra di accesso rapido
- sulla barra multifunzione
- sul foglio stesso
- al caricamento del file sfruttando l’evento Private Sub Workbook_Open()
Dim foglio As Worksheet
Dim prec As String
Dim corr As String
Dim sposta As Boolean
Dim primo As Boolean
Dim i As Integer
sposta = True
While sposta = True
primo = True
sposta = False
prec = ""
corr = ""
For Each foglio In Worksheets
If primo Then
corr = LCase(foglio.Name)
primo = False
Else
prec = corr
corr = LCase(foglio.Name)
End If
If prec <> "" Then
If corr < prec Then
sposta = True
foglio.Move Before:=Sheets(prec)
End If
End If
Next
Wend
Segui ML Training sui Social:
Facebook – LinkedIn – Twitter – Google+
Letto: 20