Hello all,
I have individual sheets in a workbook named for each Shipping Agent at my workplace. In these sheets they log their parcel counts as they ship an order. They must (it's a required field) select their name from a drop-down list in column J:J so that another sheet can calculate their totals for week/month/year etc,,,. That's the backstory..
My question is... Sometimes they must log some of the shipment cases for another Agent that originally started the order and they then finished... thus, selecting that Agent's name from the drop-down. I scoured the internet, here included, and found VBA Code that will, when column J:J is changed, move the whole Row to that Agents Sheet that was picked from the drop down. What I need the code to do BEFORE it does that, is compare the name the Agent selected from the drop-down list in column J:J to the their name on the Worksheet. If they're the same, meaning the Agent is entering their own data in DO NOTHING. If they're not, meaning the Agent is entering another Agents data, then move the whole row, not going past Column J:J, to the last row of corresponding Agents sheet. (Which, again, it is currently doing that last part correctly...it's just doing it for every entry at present.)
I know this isn't the correct way to do this...but couldn't find how.. but here's my current code:
If Not Intersect(Target, Range("J:J")) Is Nothing Then
Application.EnableEvents = False
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
Dim r As Long
Dim Lastrow As Long
Dim ans As String
ans = Target.Value
r = Target.Row
Lastrow = Sheets(ans).Cells(Rows.Count, "J").End(xlUp).Row + 1
Rows(r).Copy Sheets(ans).Rows(Lastrow)
Rows(r).Delete
MsgBox "Row Moved"
End If
Application.EnableEvents = True
Windows 7 Pro 64bit
Excel 2013 (yeah I know it's old.. but hey...it was free)
not sure what else is needed here
but everything else is up-to-date!
Thanks in advance for any and all help!!!!
J.T.
I have individual sheets in a workbook named for each Shipping Agent at my workplace. In these sheets they log their parcel counts as they ship an order. They must (it's a required field) select their name from a drop-down list in column J:J so that another sheet can calculate their totals for week/month/year etc,,,. That's the backstory..
My question is... Sometimes they must log some of the shipment cases for another Agent that originally started the order and they then finished... thus, selecting that Agent's name from the drop-down. I scoured the internet, here included, and found VBA Code that will, when column J:J is changed, move the whole Row to that Agents Sheet that was picked from the drop down. What I need the code to do BEFORE it does that, is compare the name the Agent selected from the drop-down list in column J:J to the their name on the Worksheet. If they're the same, meaning the Agent is entering their own data in DO NOTHING. If they're not, meaning the Agent is entering another Agents data, then move the whole row, not going past Column J:J, to the last row of corresponding Agents sheet. (Which, again, it is currently doing that last part correctly...it's just doing it for every entry at present.)
I know this isn't the correct way to do this...but couldn't find how.. but here's my current code:
If Not Intersect(Target, Range("J:J")) Is Nothing Then
Application.EnableEvents = False
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
Dim r As Long
Dim Lastrow As Long
Dim ans As String
ans = Target.Value
r = Target.Row
Lastrow = Sheets(ans).Cells(Rows.Count, "J").End(xlUp).Row + 1
Rows(r).Copy Sheets(ans).Rows(Lastrow)
Rows(r).Delete
MsgBox "Row Moved"
End If
Application.EnableEvents = True
Windows 7 Pro 64bit
Excel 2013 (yeah I know it's old.. but hey...it was free)
not sure what else is needed here
but everything else is up-to-date!
Thanks in advance for any and all help!!!!
J.T.