Ajuda com código VBA

Germa

27-01-2020 15:57:03

Boa tarde pessoal!
Poderiam me ajudar com esse código, o que esta errado? Ele funciona, mas quando executo dá erro e quando vou em depurar joga para a linha "If Target.Column <> 6 Then Exit Sub"

Código: Selecionar todos

Private Sub Worksheet_Change(ByVal Target As Range)

    'C01
    If Target.Column <> 6 Then Exit Sub
    If Target.Value = 1 Then
        Dim LR1 As Long
        With Sheets("C01")
            LR = .Cells(Rows.Count, 1).End(xlUp).Row
            .Cells(LR + 1, 1).Resize(, 5).Value = Cells(Target.Row, 1).Resize(, 5).Value
        End With
        Rows(Target.Row).Delete


        'C02
        If Target.Column <> 6 Then Exit Sub
        If Target.Value = 2 Then
            Dim LR2 As Long
            With Sheets("C02")
                LR2 = .Cells(Rows.Count, 1).End(xlUp).Row
                .Cells(LR2 + 1, 1).Resize(, 5).Value = Cells(Target.Row, 1).Resize(, 5).Value
            End With
            Rows(Target.Row).Delete


            'C03
            If Target.Column <> 6 Then Exit Sub
            If Target.Value = 3 Then
                Dim LR3 As Long
                With Sheets("C03")
                    LR3 = .Cells(Rows.Count, 1).End(xlUp).Row
                    .Cells(LR3 + 1, 1).Resize(, 5).Value = Cells(Target.Row, 1).Resize(, 5).Value
                End With
                Rows(Target.Row).Delete


                'C04
                If Target.Column <> 6 Then Exit Sub
                If Target.Value = 4 Then
                    Dim LR4 As Long
                    With Sheets("C04")
                        LR4 = .Cells(Rows.Count, 1).End(xlUp).Row
                        .Cells(LR4 + 1, 1).Resize(, 5).Value = Cells(Target.Row, 1).Resize(, 5).Value
                    End With
                    Rows(Target.Row).Delete

                End If
            End If
        End If
    End If


End Sub

Wagner Morel

28-01-2020 13:32:59

Germa,

Bom dia!

Sugiro anexar o arquivo aqui para que possamos rodar, depurar e saber se ocorre o erro, bem como que erro é esse.

Germa

28-01-2020 14:07:47

Wagner, bom dia!
Agradeço pela intenção em ajudar. Consegui resolver o problema aqui utilizando um outro codigo. Mas de qualquer forma obrigado.