Macro to compare date in number and product

K0st4din

Active Member
Joined
Feb 8, 2012
Messages
488
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. Windows
Hello everyone.
I have another problem with my previous file that I need to finish.
Because I want to make it clear I'll attach the files and pictures before the middle, and what can be the end of this table.
I would be very grateful if you assist in this task with a macro.
7076329I.jpg
7076330a.jpg
7076331X.jpg
7076333a.jpg
File to download
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Give this a test.
Code:
Sub deldupe()
Dim sh As Worksheet, lr As Long
Set sh = Sheets(1) 'Edit Sheet name
lr = sh.Cells(Rows.Count, 11).End(xlUp).Row
sh.UsedRange.Sort sh.Range("K1"), xlAscending, Header:=xlYes
    For i = lr To 2 Step -1
        If sh.Cells(i, 11) = sh.Cells(1 - 1, 11) Then
            Rows(i).Delete
        End If
    Next
End Sub
 
Upvote 0
2007, but it should be for .xls file, no for .xlsx
 
Upvote 0
It gives me error can be seen in the image and whether it could be done with letters, because these numbers confuse me (1 -1.11).
Thank you in advance.
7076601H.jpg
 
Upvote 0
Had a typo. This should run.
Code:
Sub deldupe()
Dim sh As Worksheet, lr As Long
Set sh = Sheets(1) 'Edit Sheet name
lr = sh.Cells(Rows.Count, 11).End(xlUp).Row
sh.UsedRange.Sort sh.Range("K1"), xlAscending, Header:=xlYes
    For i = lr To 2 Step -1
        If sh.Cells(i, 11).Value = sh.Cells(i - 1, 11).Value Then
            Rows(i).Delete
        End If
    Next
End Sub
 
Upvote 0
Took a second look at your sheet and thought maybe this modified version might be more appropriate for your needs.
Code:
Sub deldupe2()
Dim sh As Worksheet, lr As Long
Set sh = Sheets(1) 'Edit Sheet name
lr = sh.Cells(Rows.Count, 11).End(xlUp).Row
sh.UsedRange.Sort sh.Range("K1"), xlAscending, Header:=xlYes
    For i = lr To 2 Step -1
        If sh.Cells(i, 11).Value = sh.Cells(i - 1, 11).Value And _
            sh.Cells(i, 7).Value = sh.Cells(i - 1, 7).Value And _
            sh.Cells(i, 4).Value - sh.Cells(i - 1, 4).Value Then
            Rows(i).Delete
        End If
    Next
End Sub
 
Upvote 0
Hello JoeMo, I am thinking to use this option to excel , but it is clear just me and one of my colleagues , which in turn led it to seek a macro option to allow others only to press .


Hello JLGWhiz,
Both macro work almost perfectly (and if no option will remain one) , but I have only one question : Why after I activate the macro , the second name me getting it in the first position and then the other names already down?
Try it - I have attached a example.
Because this is just an example and I have over 20 000 lines and if you make this mistake gets me every name in the first position will be big trouble. Ie the last attached picture shows that finish first name and starts the next name.
7077047p.jpg
7077048g.jpg

7076333a.jpg


Names must be one after another, and now is a "mish mash" (Picture 2)
 
Upvote 0
, but I have only one question : Why after I activate the macro , the second name me getting it in the first position and then the other names already down?
That is probably due to the sort routine. Only one sort field is specified in the code I posted. But all data related to any name stays with that name. The sort routine does not cause the data to mix from one name to the other. I didn't want to use more than one sort field because it might have mixed the data. But if the names need to be in a certain order, then you could do a manual sort after the duplicates are eliminated. Or maybe try the built in duplicate remover that JoeMo suggested.
 
Upvote 0

Forum statistics

Threads
1,215,676
Messages
6,126,165
Members
449,295
Latest member
DSBerry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top