Hi guys
I have the following code which has stoped working properly. Could you provide any help?
Just to note: On every sheet all the rows are hidden except for the rows populated with data.
1) When a record is being copied across to the respective sheet, I would like the code below to unhide the row it has pasted in to the new sheet.
2) For some reason when I use the below code to move a record, it is currently deletes the data from the original soure which is FINE, however for some reason it seems to unhide around 10-100 rows in the original sheet for no reason at all??
Is thre anything in the code that is causing this?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim sResp As String
If Application.CountIf(Target, "=") = Target.Cells.Count Then Exit Sub
Application.ScreenUpdating = False
Application.EnableEvents = False
On Error Resume Next
If Not Intersect(Target, Range("J26:J200")) Is Nothing Then
If Target.Cells(1).Value = "Delete Task" Then
Target.Select
sResp = MsgBox("Are you sure you want to move this record to the 'Delete' sheet?", vbQuestion + vbYesNo)
If sResp = vbYes Then
Target.EntireRow.Copy
Sheets("Delete").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial
Target.EntireRow.Delete
Application.CutCopyMode = False
Target.Select
MsgBox " Completed task successfully moved to the following sheet -> 'Deleted' <- ."
End If
ElseIf Target.Cells(1).Value = "Move to Service Improvement WIP" Then
sResp = MsgBox("Are you sure you want to move this record to the 'Service Improvement WIP' sheet?", vbQuestion + vbYesNo)
If sResp = vbYes Then
Target.EntireRow.Copy
Sheets("Service Improvement WIP").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial
Target.EntireRow.Delete
Application.CutCopyMode = False
Target.Select
MsgBox " The selected task has been successfully moved to 'Service Improvement WIP'."
End If
ElseIf Target.Cells(1).Value = "Completed" Then
sResp = MsgBox("Are you sure you want to move this record to the 'Completed' sheet?", vbQuestion + vbYesNo)
If sResp = vbYes Then
Target.EntireRow.Copy
Sheets("Completed").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial
Target.EntireRow.Delete
Application.CutCopyMode = False
Target.Select
MsgBox " The selected task has been successfully moved to 'Completed'."
End If
ElseIf Target.Cells(1).Value = "Move to Service Improvement Workstack" Then
sResp = MsgBox("Are you sure you want to move this record to the 'Service Improvement Workstack' sheet?", vbQuestion + vbYesNo)
If sResp = vbYes Then
Target.EntireRow.Copy
Sheets("Service Improvement Workstack").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial
Target.EntireRow.Delete
Application.CutCopyMode = False
Target.Select
MsgBox " The selected task has been moved to Service Improvement Workstack."
End If
ElseIf Target.Cells(1).Value = "Move to Inbound Workstack" Then
sResp = MsgBox("Are you sure you want to move this record to the 'Inbound Workstack' sheet?", vbQuestion + vbYesNo)
If sResp = vbYes Then
Target.EntireRow.Copy
Sheets("Inbound Workstack").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial
Target.EntireRow.Delete
Application.CutCopyMode = False
Target.Select
MsgBox " The selected task has been moved to the Inbound Workstack sheet."
End If
ElseIf Target.Cells(1).Value = "Move to Inbound WIP" Then
sResp = MsgBox("Are you sure you want to move this record to the 'Inbound WIP' sheet?", vbQuestion + vbYesNo)
If sResp = vbYes Then
Target.EntireRow.Copy
Sheets("Inbound WIP").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial
Target.EntireRow.Delete
Application.CutCopyMode = False
Target.Select
MsgBox " The selected task has been moved to the Inbound WIP sheet."
End If
End If
End If
Application.EnableEvents = True
Application
.ScreenUpdating = True
End Sub
Bookmarks