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