Hey guys,
I have absolutely no idea what I have mixed up here...
I tried a bunch of different sample codes and some seems to overwrite the last row instead of going to the next blank row (only every now and then, not every time).
But the current code in the sample seems to be working to a point... It copies the entire rows to the new sheets fine, have not seen it overwrite anything at all yet.
The issue is when it copies to the remediation complete sheet the account number seems to get an additional value added to it from somewhere. Eg
account number 1 --> remediation sheet the account number changes to be 3
please see the sample sheet (excel 2010) will make it a lot easier than trying to explain. :P (must be having a total spastic day, cant seem to upload the sample so code below)
I have absolutely no idea what I have mixed up here...
I tried a bunch of different sample codes and some seems to overwrite the last row instead of going to the next blank row (only every now and then, not every time).
But the current code in the sample seems to be working to a point... It copies the entire rows to the new sheets fine, have not seen it overwrite anything at all yet.
The issue is when it copies to the remediation complete sheet the account number seems to get an additional value added to it from somewhere. Eg
account number 1 --> remediation sheet the account number changes to be 3
please see the sample sheet (excel 2010) will make it a lot easier than trying to explain. :P (must be having a total spastic day, cant seem to upload the sample so code below)
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim sht As Worksheet
Dim nxtRow As Integer
Dim lRow As Long
'Determine if change was to Column C (3)
If Target.Column = 15 Then
'If Yes, Determine if cell = "Remediation Complete"
If Target.Value = "Remediation Complete" Then
Set sht = Worksheets("Reporting Sheet")
lRow = sht.Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row
With sht
.Cells(lRow, 1).Value = Target.Cells.Offset(Target.Row, -14).Value
.Cells(lRow, 2).Value = Target.Cells.Offset(Target.Row, -13).Value
.Cells(lRow, 3).Value = Target.Cells.Offset(Target.Row, -12).Value
.Cells(lRow, 4).Value = Target.Cells.Offset(Target.Row, -11).Value
.Cells(lRow, 5).Value = Target.Cells.Offset(Target.Row, -10).Value
.Cells(lRow, 6).Value = Target.Cells.Offset(Target.Row, -9).Value
.Cells(lRow, 7).Value = Target.Cells.Offset(Target.Row, -8).Value
.Cells(lRow, 8).Value = Target.Cells.Offset(Target.Row, -7).Value
.Cells(lRow, 9).Value = Target.Cells.Offset(Target.Row, -6).Value
.Cells(lRow, 10).Value = Target.Cells.Offset(Target.Row, -5).Value
.Cells(lRow, 11).Value = Target.Cells.Offset(Target.Row, -4).Value
.Cells(lRow, 12).Value = Target.Cells.Offset(Target.Row, -3).Value
.Cells(lRow, 13).Value = Target.Cells.Offset(Target.Row, -2).Value
End With
'Delete changed row now that account has been remediated & moved to the Reporting Sheet
Target.EntireRow.Delete
ElseIf Target.Value = "O2A iTam" Or Target.Value = "Tibco iTam" Or Target.Value = "Kenan iTam" Or Target.Value = "Other iTam" Or Target.Value = "Disconnect Inprogress" Then
'If Yes, find next empty row in Reporting Sheet
Set sht = Worksheets("Outstanding - iTams")
lRow = sht.Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row
'Copy changed row and paste into Reporting Sheet
Target.EntireRow.Copy Destination:=sht.Range("A" & lRow)
'Delete changed row now that account has been remediated & moved to the Reporting Sheet
Target.EntireRow.Delete
ElseIf Target.Value = "Customer Contact" Then
'If Yes, find next empty row in Reporting Sheet
Set sht = Worksheets("Outstanding - Customer Contact")
lRow = sht.Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row
'Copy changed row and paste into Reporting Sheet
Target.EntireRow.Copy Destination:=sht.Range("A" & lRow)
'Delete changed row now that account has been remediated & moved to the Reporting Sheet
Target.EntireRow.Delete
ElseIf Target.Value = "Open Copy" Then
'If Yes, find next empty row in Reporting Sheet
Set sht = Worksheets("Outstanding - Open Copy Order")
lRow = sht.Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row
'Copy changed row and paste into Reporting Sheet
Target.EntireRow.Copy Destination:=sht.Range("A" & lRow)
'Delete changed row now that account has been remediated & moved to the Reporting Sheet
Target.EntireRow.Delete
End If
End If
End Sub