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 andriessen
Posts
#72531
Boa tarde

Sei que os feras ai vão tirar de letra, eu estou apanhando um pouco

Coluna A Coluna B Coluna C
11 1 102
11 2 102
12 1 121
13 1 152
14 1 110
15 1 86
15 2 86


Enquanto a Coluna A for "11"(Cod) e a coluna C for "102"(Apto) escreva na coluna V (=Now())
linha1 = ActiveCell.Row
While Cells(linha1, 0) = Cod And Cells(linha1, 5) = Apto
If Cells(linha1, 1) = Cod Then
If Cells(linha1, 5) = Apto Then
ActiveCell.Offset(0, 20) = Now()
'ActiveCell.Select
'GoTo Fim
Else
End If
End If
linha1 = linha1 + 1
'End If
Wend

Obrigado
Avatar do usuário
Por Foxtri
Posts Avatar
#72533
Bom dia
Veja se era isso:
Sub Macro1()
Dim Rng As Range, Xrange As Range
Set Xrange = Range("A1").CurrentRegion
For Each Rng In Xrange
If Xrange(Rng.Row, 1) = 11 And Xrange(Rng.Row, 3) = 102 Then Cells(Rng.Row, 22) = Now()
Next
End Sub
HermesSantos agradeceu por isso
Por HermesSantos
#72534
Olá! Tente o seguinte código:

Sub Macro1()
Dim data As Date
Dim x As Integer
Dim Cod As Variant
Dim Apto As Variant

Cod = 11
Apto = 102
data = Now()

'Encontra número de linhas preenchidas na coluna A
NumLinhas = Range("A1", Range("A1").End(xlDown)).Rows.Count
'Seleciona a célula A1
Range("A1").Select

'Faz loop até a última linha preenchida na coluna A
For x = 0 To NumLinhas
'Verifica valor na coluna A
If ActiveCell.Value = Cod Then
'Verifica valor na coluna C
ActiveCell.Offset(0, 2).Select
If ActiveCell.Value = Apto Then
'Insere data e hora na coluna V
ActiveCell.Offset(0, 20).Value = data
'Retorna para coluna A
ActiveCell.Offset(0, -2).Select
'Vai para a próxima linha
End If

End If
ActiveCell.Offset(1, 0).Select
Next

End Sub
Você não está autorizado a ver ou baixar esse anexo.
andriessen agradeceu por isso
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