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.
#45520
Olá Senhores.

Minha macro apresenta o erro 1004 "Erro 1004 - Definição de aplicativo ou definição de objeto"

Na linha abaixo:

Nome1 = ThisWorkbook.Worksheets("Plan1").Range("A" & i).Value

Alguém consegue me ajudar?



Sub ValidarDados()

Dim i As Long

Dim UltimaLinha As Long

UltimaLinha = Sheets("Plan1").Cells(Cells.Rows.Count, 1).End(xlUp).Row

If UltimaLinha < 2 Then UltimaLinha = 2

'With ThisWorkbook.Sheets("Plan1")



Nome1 = ThisWorkbook.Worksheets("Plan1").Range("A" & i).Value
Debito = ThisWorkbook.Worksheets("Plan1").Range("C" & i).Value
Nome2 = ThisWorkbook.Worksheets("Plan1").Range("D" & i).Value
Credito = ThisWorkbook.Worksheets("Plan1").Range("F" & i).Value






For i = 2 To UltimaLinha


If Range("A" & i).Value = Range("D" & i).Value And Range("C" & i).Value = Range("F" & i).Value Then


ThisWorkbook.Worksheets("Plan1").Range("G" & i).Value = "Conciliado"



End If




Next

'End With



End Sub
Você não está autorizado a ver ou baixar esse anexo.
#45522
Note o trecho de código abaixo
Código: Selecionar todos
Sub ValidarDados()

Dim i As Long

Dim UltimaLinha As Long

UltimaLinha = Sheets("Plan1").Cells(Cells.Rows.Count, 1).End(xlUp).Row

If UltimaLinha < 2 Then UltimaLinha = 2

Nome1 = ThisWorkbook.Worksheets("Plan1").Range("A" & i).Value
Debito = ThisWorkbook.Worksheets("Plan1").Range("C" & i).Value
Nome2 = ThisWorkbook.Worksheets("Plan1").Range("D" & i).Value
Credito = ThisWorkbook.Worksheets("Plan1").Range("F" & i).Value

Note que em nenhum momento você definiu o valor da variável i. Logo, ela assume o valor de zero. Assim, você estaria tentando pegar o valor de células com linha 0, que não existem.
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