Sumanthbhe
New Member
- Joined
- Jan 2, 2022
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
I need help with Excel VBA code.
If the third column we enter -1 it will clear the row. If we enter 1000 it will be copied to another sheet and deleted from the current sheet.
The above code is working fine. Instead of clearing row data, I want to delete that row. So added Line 4 With Target.EntireRow.ClearContents to With Target.EntireRow.Delete But it shows an error.
Someone, please help.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 And Target.Cells.Count = 1 Then
If LCase(Target.Value) = "-1" Then
With Target.EntireRow.ClearContents
End With
End If
End If
If Target.Column = 3 And Target.Cells.Count = 1 Then
If LCase(Target.Value) = "1000" Then
With Target.EntireRow
.Copy Sheets("Week Schedule").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
.Delete
End With
End If
End If
End Sub
If the third column we enter -1 it will clear the row. If we enter 1000 it will be copied to another sheet and deleted from the current sheet.
The above code is working fine. Instead of clearing row data, I want to delete that row. So added Line 4 With Target.EntireRow.ClearContents to With Target.EntireRow.Delete But it shows an error.
Someone, please help.