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
Por SandroLima
#55392
Boa noite, pessoal

Estou aproveitando essa macro de uma outra planilha e nesta ela não faz a organização das datas.

Poderiam me apontar o erro?

Segue planilha anexa.
Você não está autorizado a ver ou baixar esse anexo.
Por SandroLima
#55413
Boa tarde, pessoal

Alguém sabe o erro que estou fazendo?

Transcrevi essa macro de outra planilha... serve para ordenar conforme as datas.

Alguém poderia apontar qual meu erro?
Avatar do usuário
Por JCabral
Avatar
#55416
Caro SandroLima

Essa sua macro, Ordena_Itens_Serviços, não ordena rigorosamente nada!

Pretende ordenar a sua tabela, como? Pela data?
Por babdallas
#55423
Código: Selecionar todos
Tabela.DataBodyRange.Sort Key1:=Tabela.ListColumns("Data").DataBodyRange, _
                                Order1:=xlAscending, Header:=xlYes
Por SandroLima
#55457
Boa noite, prezados.

Consegui finalmente ajustar.

A macro funciona corretamente e preciso dela nessa estrutura pq serão inseridos vários passos para o correto ordenamento.

O primeiro erro estava nessa linha:
Código: Selecionar todos
Set RngCol = Range(Cells(IniLin, ColNum), Cells(UltLin, ColNum))
O correto era:
Código: Selecionar todos
Set RngCol = Range(Cells(IniLin, ColData), Cells(UltLin, ColData))
E depois ao final do código estava faltando esse trecho:
Código: Selecionar todos
If Not RngTabela Is Nothing Then
            Plan.Sort.SortFields.Clear
            Plan.Sort.SortFields.Add Key:=RngCol, _
                SortOn:=SortTipo, Order:=SortOrdem, DataOption:=xlSortNormal
                
            With Plan.Sort
                .SetRange RngTabela: .Header = xlGuess: .MatchCase = False
                .Orientation = xlTopToBottom: .SortMethod = xlPinYin: .Apply
            End With
        End If
Agora está rodando novamente.

Muito obrigado pela ajuda.
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