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 LeoHenrique
Posts Avatar
#61091
Bom dia a todos !

Pessoal, preciso que o código abaixo coloque em ordem 6 colunas, a primeira é o nome do cliente e as demais é o ano de 2017 á 2021, colocando em ordem decrescente primeiro o ano de 2021, após o ano de 2020 e assim por diante. O problema é que a base de clientes (quantidade) muda ANTES de rodar a macro, sendo que o código abaixo quando gravei a macro, vai até a linha 36, mas essa quantidade muda... se alguém puder me ajudar, desde já agradeço.



Range("NS5:NX5").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Selecionado").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Selecionado").Sort.SortFields.Add2 Key:=Range( _
"NX6:NX36"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Selecionado").Sort.SortFields.Add2 Key:=Range( _
"NW6:NW36"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Selecionado").Sort.SortFields.Add2 Key:=Range( _
"NV6:NV36"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Selecionado").Sort.SortFields.Add2 Key:=Range( _
"NU6:NU36"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Selecionado").Sort.SortFields.Add2 Key:=Range( _
"NT6:NT36"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Selecionado").Sort
.SetRange Range("NS5:NX36")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("NS5").Select
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