Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
Avatar do usuário
Por ruymds
Posts Avatar
#24031
Olá pessoal,

possuo uma macro (anexa) para ordenar uma quantidade de valores (menor para o maior) porém gostaria que a mesma fizesse a ordenação também por ordem de sequência...

exemplo:

Original
1 2 3 5 7 11 12 13 16 17 18 19 22 23 24
1 3 4 7 9 11 12 13 14 16 17 18 19 22 23
1 3 4 5 7 11 12 13 14 16 17 19 22 23 24
1 3 4 5 9 10 11 12 16 17 19 20 21 23 24
1 2 3 5 7 10 11 12 16 17 18 19 22 23 24
1 3 4 5 9 11 12 13 14 16 17 18 21 23 24

Ordenada
1 2 3 5 7 10 11 12 16 17 18 19 22 23 24
1 2 3 5 7 11 12 13 16 17 18 19 22 23 24
1 3 4 5 7 11 12 13 14 16 17 19 22 23 24
1 3 4 5 9 10 11 12 16 17 19 20 21 23 24
1 3 4 5 9 11 12 13 14 16 17 18 21 23 24
1 3 4 7 9 11 12 13 14 16 17 18 19 22 23

Grato.
Você não está autorizado a ver ou baixar esse anexo.
#24044
Código: Selecionar todos
Sub OrdenaLinhasV3()
 Dim k As Long, LR As Long
  Application.ScreenUpdating = False
  LR = Cells(Rows.Count, 1).End(3).Row
  For k = 1 To LR
   Cells(k, 1).Resize(, 15).Sort Key1:=Cells(k, 1), Order1:=xlAscending, Orientation:=xlLeftToRight
  Next k

  With ActiveWorkbook.ActiveSheet.Sort
   .SortFields.Clear
   .SortFields.Add Key:=Range("A1:A" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("B1:B" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("C1:C" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("D1:D" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("E1:E" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("F1:F" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("G1:G" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("H1:H" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("I1:I" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("J1:J" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("K1:K" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("L1:L" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("M1:M" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("N1:N" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SortFields.Add Key:=Range("O1:O" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
   .SetRange Range("A1:O" & LR)
   .Header = xlNo
   .MatchCase = False
   .Orientation = xlTopToBottom
   .SortMethod = xlPinYin
   .Apply
  End With
 Application.ScreenUpdating = True
End Sub

long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord