Find duplicates starting from today

Status
Not open for further replies.

SamPaulRoger

New Member
Joined
Jul 28, 2018
Messages
12
Hi,

I have two tables, one is a data output that I have to analyze, the other is a list of unique values where I need to know if there are any duplicates that fall between today's date and beyond.

Sheet1

7/257/267/277/287/297/307/318/18/28/3
ABC109ABC100ABC100ABC100DCV394DEF101DEF101QVS001
ABC101DEF102DEF103ABC101QWE502DEF102DEF102
QWE501FBB100DCV393ABC101DEF103DEF103

<tbody>
</tbody>

For example, assuming today is 7/27, the script would start counting duplicates and output the count in the table on Sheet2

ID #Duplicates
ABC1002
ABC1012
FBB1000
DEF1000
DEF1012
DEF1022
DEF1033
DCV3930

<tbody>
</tbody>
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I think this will do it. Your sample data seems to be providing a count only, so that's what I include.


Book1
ABCDEFGHI
17/25/187/26/187/27/187/28/187/29/187/30/187/31/188/01/188/02/18
2ABC109ABC100ABC100ABC100DCV394DEF101DEF101
3ABC101DEF102DEF103ABC101QWE502DEF102DEF102
4QWE501FBB100DCV393ABC101DEF103DEF103
5
67/27/18
7ID #Count
8ABC1002
9ABC1012
10FBB1001
11DEF1000
12DEF1012
13DEF1022
14DEF1033
15DCV3931
Sheet23
Cell Formulas
RangeFormula
B8=SUMPRODUCT(($A$1:$J$1>=$A$6)*($A$2:$J$4=A8))
 
Upvote 0
Alright, so this worked, however, it is extremely slow for the actual data set, I am looking up 9000 values in a range that is A1:ZZ500, Is there any way to have this done faster with vba?
 
Upvote 0
1. Are these real dates, or text dates?
2. I have a feeling that formulas will probably be faster than VBA
 
Upvote 0
Try PowerQuery

result table:

ValueCount
ABC100
2​
DEF103
3​
ABC101
2​
DEF101
2​
DEF102
2​

M Code:
Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"25/07/2018", type text}, {"26/07/2018", type text}, {"27/07/2018", type text}, {"28/07/2018", type text}, {"29/07/2018", type text}, {"30/07/2018", type text}, {"31/07/2018", type text}, {"01/08/2018", type text}, {"02/08/2018", type text}, {"03/08/2018", type text}}),
    #"Demoted Headers" = Table.DemoteHeaders(#"Changed Type"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Demoted Headers",{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}, {"Column7", type text}, {"Column8", type text}, {"Column9", type text}, {"Column10", type text}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type1"),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Transposed Table", {"Column1"}, "Attribute", "Value"),
    #"Changed Type2" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Column1", type date}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type2", each [Column1] >= #date(2018, 7, 27)),
    #"Kept Duplicates" = let columnNames = {"Value"}, addCount = Table.Group(#"Filtered Rows", columnNames, {{"Count", Table.RowCount, type number}}), selectDuplicates = Table.SelectRows(addCount, each [Count] > 1), removeCount = Table.RemoveColumns(selectDuplicates, "Count") in Table.Join(#"Filtered Rows", columnNames, removeCount, columnNames, JoinKind.Inner),
    #"Grouped Rows" = Table.Group(#"Kept Duplicates", {"Value"}, {{"Count", each Table.RowCount(_), type number}})
in
    #"Grouped Rows"[/SIZE]
 
Upvote 0
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,849
Messages
6,121,922
Members
449,056
Latest member
denissimo

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