- 05 Mar 2022 às 15:14
#69466
Pessoal estou desenvolvendo uma planilha para controle financeiro. Ela é bem simples. Eu gostaria de escrever um código VBA que classificasse o ano e o mês. Classificar o ano eu até consegui, porém, não consigo que o VBA classifique o mês, pois, ele entende que é para classificar em ordem alfabética, tipo, A, B, C (...). Então, ele joga Fev, antes de Jan, por exemplo. Segue anexo o código que eu usei. Agradeço a ajuda, desde já. Obrigado.
Public Sub classificar ( )
Dim tabela As Range
wsbase.Sort.SortFields.Clear
Set tabela = Range("A2").CurrentRegion
With wsbase.Sort
.SortFields.Add tabela.Columns(1), xlSortOnValues, xlAscending
.SortFields.Add tabela.Columns(2), xlSortOnValues, xlAscending
End With
Plan1.Sort.SetRange tabela
Plan1.Sort.Header = xlYes
Plan1.Sort.Apply
End Sub
Public Sub classificar ( )
Dim tabela As Range
wsbase.Sort.SortFields.Clear
Set tabela = Range("A2").CurrentRegion
With wsbase.Sort
.SortFields.Add tabela.Columns(1), xlSortOnValues, xlAscending
.SortFields.Add tabela.Columns(2), xlSortOnValues, xlAscending
End With
Plan1.Sort.SetRange tabela
Plan1.Sort.Header = xlYes
Plan1.Sort.Apply
End Sub