Views

Histats

Vitrine

VBA Excel - Ordenando Alfabeticamente as Abas - Sort all worksheets on the basis of Sheet names

Inline image 1


Quando a nossa aplicação gera novas abas com conteúdo no MS Excel, é importante que ordenemos o resultado. Como?

Sub SortALLSheets()

  'This module will sort all the worksheets present in active workbook.
  Dim iSheet As Long, iBefore As Long

  For iSheet = 1 To ActiveWorkbook.Sheets.count

    Sheets(iSheet).Visible = True

    For iBefore = 1 To iSheet - 1
      If UCase(Sheets(iBefore).Name) > UCase(Sheets(iSheet).Name) Then
        ActiveWorkbook.Sheets(iSheet).Move before:=ActiveWorkbook.Sheets(iBefore)

        Exit For
      End If
    Next iBefore

  Next iSheet

End Sub

Tags: VBA, Excel, ordenar, alfabético, sort, worksheets, 



✔ VBA Brazil®

✔ VBA Brazil®
brazilsalesforceeffectiveness@gmail.com
Related Posts Plugin for WordPress, Blogger...
diHITT - Notícias