My macro below as can be seen when a condition is achieved ('ongoing' is typed in the master work sheet) in a column that line of data is moved into a work sheet called ONGOING.
When the word 'complete is typed into the master work sheet the data on that line is moved into a work sheet called 'COMPLETE' and that line that was in the ONGOING sheet is deleted.
Works perfectly as is but..
I want to remove columns in the master sheet ie move the 'Status' column that registers ongoing or complete from column 'X' to column 'U'.
So I adjusted the macro accordingly.
Works perfectly with the exception the 'ONGOING' sheet doesn't annotated that is the 'foundCase.EntireRow.Delete' function doesn't work.
Can some one tell me what else in the code needs adjusting please.
Fred
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("X:X")) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Dim bottomH As Long
Dim bottomC As Long
Dim rng As Range
Dim foundCase As Range
If Target = "ongoing" Then
bottomC = Sheets("ONGOING").Range("C" & Rows.Count).End(xlUp).Row
Set foundCase = Sheets("ONGOING").Range("C2:C" & bottomC).Find(Target.Offset(0, -16), LookIn:=xlValues, LookAt:=xlWhole)
If Not foundCase Is Nothing Then
'Target.EntireRow.Copy Sheets("ONGOING").Range("A" & foundCase.Row)
Range("A" & Target.Row).Copy Sheets("ONGOING").Range("A" & foundCase.Row)
Range("G" & Target.Row & ":I" & Target.Row).Copy Sheets("ONGOING").Range("B" & foundCase.Row)
Range("J" & Target.Row & ":K" & Target.Row).Copy Sheets("ONGOING").Range("E" & foundCase.Row)
Range("S" & Target.Row).Copy Sheets("ONGOING").Range("G" & foundCase.Row)
'Range("V" & Target.Row).Copy Sheets("ONGOING").Range("G" & foundCase.Row)'
Range("X" & Target.Row).Copy Sheets("ONGOING").Range("H" & foundCase.Row)
Else
Range("A" & Target.Row).Copy Sheets("ONGOING").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
Range("G" & Target.Row & ":I" & Target.Row).Copy Sheets("ONGOING").Cells(Rows.Count, "B").End(xlUp).Offset(1, 0)
Range("J" & Target.Row & ":K" & Target.Row).Copy Sheets("ONGOING").Cells(Rows.Count, "E").End(xlUp).Offset(1, 0)
Range("S" & Target.Row).Copy Sheets("ONGOING").Cells(Rows.Count, "G").End(xlUp).Offset(1, 0)
'Range("V" & Target.Row).Copy Sheets("ONGOING").Cells(Rows.Count, "G").End(xlUp).Offset(1, 0)'
Range("X" & Target.Row).Copy Sheets("ONGOING").Cells(Rows.Count, "H").End(xlUp).Offset(1, 0)
End If
ElseIf Target = "complete" Then
bottomH = Sheets("COMPLETE").Range("H" & Rows.Count).End(xlUp).Row
Set foundCase = Sheets("COMPLETE").Range("H2:H" & bottomH).Find(Target.Offset(0, -16), LookIn:=xlValues, LookAt:=xlWhole)
If Not foundCase Is Nothing Then
Target.EntireRow.Copy Sheets("COMPLETE").Range("A" & foundCase.Row)
Else
Target.EntireRow.Copy Sheets("COMPLETE").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End If
bottomC = Sheets("ONGOING").Range("C" & Rows.Count).End(xlUp).Row
Set foundCase = Sheets("ONGOING").Range("C2:C" & bottomC).Find(Target.Offset(0, -16), LookIn:=xlValues, LookAt:=xlWhole)
If Not foundCase Is Nothing Then
foundCase.EntireRow.Delete
End If
End If
End Sub
Bookmarks