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.
Por Domingsp
Posts
#26191
Olá, tenho um codigo com o objetivo de colocar, em ordem crescente na Coluna C, 4 valores que estão em Col A. Isso é feito ao acionar o botão verde associado a macro ORDENA. Só que nada ocorre ao executar.
Ao depurar o codigo é apontado "Erro de definição de aplicativo ou de definição de objeto".
Não sei onde está o erro. Se alguem puder dar uma olhada, fico grato.
O código abaixo e anexei a pasta ORDENACAO em que é executada a macro
Código: Selecionar todos
Sub ORDENA() ' Ordenar 4 Numeros em Crescente
Dim m As Integer, n As Integer, Aux As Integer
 Sheets("Plan1").Activate
    For m = 1 To 3
        For n = m + 1 To 4
            If Cells(m, 1) > Cells(n, 1) Then
                Aux = Cells(n, 1)
                Cells(n, 1) = Cells(m, 1)
                Cells(m, 1) = Aux
                Cells(i + 1, 3) = Cells(m, 1): i = i + 1
            End If
        Next n
    Next m
End Sub
Você não está autorizado a ver ou baixar esse anexo.
Por osvaldomp
#26197
Experimente:
Código: Selecionar todos
Sub ORDENAV2() ' Ordenar 4 Numeros em Crescente
Dim m As Integer, n As Integer, Aux As Integer
 Sheets("Plan1").Activate
    For m = 1 To 3
        For n = m + 1 To 4
            Cells(m, 3) = Cells(m, 1): Cells(m + 1, 3) = Cells(m + 1, 1)
            If Cells(m, 1) > Cells(n, 1) Then
                Aux = Cells(n, 1)
                Cells(n, 1) = Cells(m, 1)
                Cells(m, 1) = Aux
                Cells(m, 3) = Aux: Cells(m + 1, 3) = Cells(n, 1)
            End If
        Next n
    Next m
End Sub
no lugar desta linha
Código: Selecionar todos
Cells(m, 3) = Aux: Cells(m + 1, 3) = Cells(n, 1)
você pode utilizar uma das duas abaixo
Código: Selecionar todos
Cells(m, 3) = Cells(m, 1): Cells(m + 1, 3) = Cells(n, 1)
Cells(m, 3) = Cells(m, 1): Cells(m + 1, 3) = Cells(m + 1, 1)
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