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 JayltonLuiz
Posts
#27018
Bom Dia,

Estou tentando colocar a função If Not Intersect para 3 colunas esta dando erro.


Private Sub Worksheet_Change(ByVal Target As Range)

'If Not Intersect(Target, Columns("C")) Is Nothing Then (Preciso acrescentar a coluna F e I )

'For iCol = 2 To Target.Columns.Count
'Set iCell = Target(iRow, iCol)

Plan4.Range("E" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = Target.Offset(0, -2)
Plan4.Range("F" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = Target.Offset(0, 0)
Plan4.Range("C" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = VBA.Environ("username")
Plan4.Range("B" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = Now()
'Plan4.Range("A" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = iCell.Address(0, 0)
Plan4.Range("D" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = Target.Offset(0, 7)


'NowValue = Now

'If iLogRow Mod 100 = 0 Then DoEvents

'Next iCol


End If
End Sub
Avatar do usuário
Por alexandrevba
Avatar
#27019
Bom dia!!

Já tentou isso...
Código: Selecionar todos
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Columns("c")) Is Nothing Then '(Preciso acrescentar a coluna F e I )
        For iCol = 2 To Target.Columns.Count
            Set iCell = Target(iRow, iCol)
            Plan4.Range("E" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = Target.Offset(0, -2)
            Plan4.Range("F" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = Target.Offset(0, 0)
            Plan4.Range("C" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = VBA.Environ("username")
            Plan4.Range("B" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = Now()
            Plan4.Range("A" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = iCell.Address(0, 0)
            Plan4.Range("D" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = Target.Offset(0, 7)
            NowValue = Now
            If iLogRow Mod 100 = 0 Then DoEvents
        Next iCol
    ElseIf Not Intersect(Target, Columns("F")) Is Nothing Then
    'Seu código
    ElseIf Not Intersect(Target, Columns("I")) Is Nothing Then
    'Seu código
    End If
End Sub
Att
Por osvaldomp
#27023
Código: Selecionar todos
If Not Intersect(Target, Range("C:C,F:F,I:I")) Is Nothing Then
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