Página 1 de 1

If Not Intersect

Enviado: 04 Out 2017 às 10:30
por JayltonLuiz
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

Re: If Not Intersect

Enviado: 04 Out 2017 às 11:16
por alexandrevba
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

Re: If Not Intersect

Enviado: 04 Out 2017 às 12:23
por osvaldomp
Código: Selecionar todos
If Not Intersect(Target, Range("C:C,F:F,I:I")) Is Nothing Then

Re: If Not Intersect

Enviado: 04 Out 2017 às 12:41
por JayltonLuiz
Obrigado você e o cara mesmo.