Sort/Duplicate Help

  • Thread starter Thread starter nascarjc
  • Start date Start date
N

nascarjc

Hello All,
This is what I am trying to do. I am new at this and have been trying
for a couple of weeks.
Truck # Date Checked Engine #
36481 6/28/06 3cs26898
36498 6/26/06 3cs27391
36507 7/5/06 3cs27750
36526 6/26/06 3cs28760
36526 6/28/06 3cs28760
36539 6/26/06 3cs28972
36540 7/5/06 3cs28990
36550 6/28/06 3cs28983
36552 6/26/06 3cs28920
36553 6/28/06 3cs28921
36558 7/5/06 3cs28595

I want to sort column A then include B & C (expand selection) I think
it says, then check for duplicate Truck #'s and delete or remove the
duplicate truck # row.
Hope this makes sense.
Any help would be appreicated. Thx in advance
James
 
Sub FixData()
Dim lastrow as Long, i as Long
Range(A:C).Sort Key1:=Range("A2"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
lastrow = cells(rows.count,1).End(xlup).Row
for i = lastrow - 1 to 2 step - 1
if cells(i,1) = cells(i+1,1) then
rows(i).Delete
end if
Next
End Sub

Test it on a copy of your data.
 
Hi Tom,
Thanks for the help. I will give it a try and get back to you on ho
it went.
Jame
 
Hello Tom,
I tried the code for the sort and works great and I like how it does
it. One thing maybe I should have mentioned before also. When it
deletes the duplicates, it erases all the codes I have in it. The page
I am sorting and deleting the duplicates, it is copying data from
another page.
What you gave me though is great, I wish I could come up with code that
fast. Thanks for your help it is much appreicated. If you need my
codes I would gladly put it on also.
James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top