how to count duplicates values in a day

AYSHANA

Board Regular
Joined
Oct 16, 2021
Messages
90
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
good day!
i would like to count (how many duplicate pt number I have in a day based on (orders)

thank you.

Book2.xlsx
ABCDEFGHIJKL
1OrdersPT NumberResult Date TimeHOW MANY DUPLICATE PT NUMBER I HAVE IN A DAY BASED ON ORDERS
2BGRPS113/1/2023 22:562023
3BGRPS123/1/2023 13:04
4BGRP123333/1/2023 20:24ROLEJANFEBMARAPRMAY
5BGRPS1233/1/2023 19:21BGRPS WITH BGRPS001
6%XM1233/1/2023 21:53BGRPS WITH %XM002
7BGRPS34553/1/2023 16:24
8BGRPS55563/1/2023 21:22
9BGRP66773/1/2023 20:49
10BGRPS7773/9/2023 16:57
11BGRPS2343/9/2023 3:04
12%XM2343/9/2023 20:54
13BGRPS6663/10/2023 20:32
14BGRPS66553/10/2023 10:22
15BGRPS5433/10/2023 6:36
16BGRPS2453/10/2023 7:40
17BGRPS2453/10/2023 6:43
18BGRP34453/10/2023 23:03
19%XM45563/10/2023 8:51
20%XM55543/1/2023 13:50
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B:BCell ValueduplicatestextNO
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Use UDF.
Right click tab's name, ViewCode then Insert/Module, paste below code into. Save file as .xlsm

Format: =dup(DataRange,month,year,1 or 2)
In H5:
=dup($A$2:$C$20,H$4,$J$2,1)
H6:
=dup($A$2:$C$20,H$4,$J$2,2)
Copy both accross
Capture.JPG

PHP:
Option Explicit
Function Dup(ByVal rng As Range, month As Range, year As Range, n As Integer)
Dim StartD, EndD, i&, rng2, dic1 As Object, dic2 As Object, key1, key2, c1&, c2&
Set dic1 = CreateObject("Scripting.Dictionary")
Set dic2 = CreateObject("Scripting.Dictionary")
StartD = DateValue("01-" & month & "-" & year)
EndD = WorksheetFunction.EoMonth(StartD, 0)
rng2 = rng.Value
For i = 1 To UBound(rng2)
    If rng2(i, 3) >= StartD And rng2(i, 3) <= EndD Then
        If rng2(i, 1) = "BGRPS" Then
           If Not dic1.exists(rng2(i, 2)) Then
                dic1.Add rng2(i, 2), 1
            Else
                dic1(rng2(i, 2)) = dic1(rng2(i, 2)) + 1
            End If
        End If
        If rng2(i, 1) = "%XM" Then
           If Not dic2.exists(rng2(i, 2)) Then
                dic2.Add rng2(i, 2), 1
            Else
                dic2(rng2(i, 2)) = dic2(rng2(i, 2)) + 1
            End If
        End If
    End If
Next
For Each key1 In dic1.keys
    If dic1(key1) > 1 Then
        c1 = c1 + 1
    Else
        For Each key2 In dic2.keys
            If key1 = key2 Then
                c2 = c2 + 1
                Exit For
            End If
        Next
    End If
Next
Dup = IIf(n = 1, c1, c2)
End Function
 
Upvote 0
Hi. You can try it with:

PHP:
Sub Macro1()
Dim a, C As Range, j%, i&
ReDim a(1 To 2, 1 To Range("G4", [g4].End(xlToRight)).Columns.Count - 1)
For i = 2 To [a1].End(xlDown).Row - 1
  Set C = Cells(i, 1)
  If C(1, 2) = C(2, 2) Then
    If C = C(2) Then j = 1 Else j = 2
    a(j, Month(C(, 3))) = 1 + a(j, Month(C(, 3)))
    i = 1 + i
  End If
Next
[h5].Resize(2, UBound(a, 2)) = a
End Sub
 
Upvote 0
Hi. You can try it with:

PHP:
Sub Macro1()
Dim a, C As Range, j%, i&
ReDim a(1 To 2, 1 To Range("G4", [g4].End(xlToRight)).Columns.Count - 1)
For i = 2 To [a1].End(xlDown).Row - 1
  Set C = Cells(i, 1)
  If C(1, 2) = C(2, 2) Then
    If C = C(2) Then j = 1 Else j = 2
    a(j, Month(C(, 3))) = 1 + a(j, Month(C(, 3)))
    i = 1 + i
  End If
Next
[h5].Resize(2, UBound(a, 2)) = a
End Sub
it is working

but i didnt know from where the count in dec (2332) is coming from, it should be blank


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim a, C As Range, j%, i&
ReDim a(1 To 2, 1 To Range("G4", [g4].End(xlToRight)).Columns.Count - 1)
For i = 2 To [a1].End(xlDown).Row - 1
Set C = Cells(i, 1)
If C(1, 2) = C(2, 2) Then
If C = C(2) Then j = 1 Else j = 2
a(j, Month(C(, 3))) = 1 + a(j, Month(C(, 3)))
i = 1 + i
End If
Next
[h5].Resize(2, UBound(a, 2)) = a
End Sub


BGRPS STATISTICS.xlsm
ABCDEFGHIJKLMNOPQRST
1OrdersPT NumberResult Date Time
2BGRPS11481574701/03/23 22:562023
3BGRPS254468701/03/23 13:04
4BGRP265336201/03/23 20:24ROLEJANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDECTOTAL
5BGRPS267729601/03/23 19:21BGRPS WITH BGRPS152332
6%XM267729601/03/23 21:53BGRPS WITH %XM221
Sheet1
Cell Formulas
RangeFormula
A2:A6A2='raw daily'!B2
B2:B6B2='raw daily'!E2
C2:C6C2='raw daily'!I2
 
Upvote 0
In the cells of the columns A:C you can see (top left) some red "dots", right?...

I have the 'suspicion' that these cells do not contain numbers or dates but "texts" that look like numbers or dates respectively.

To check: Can you upload a small sample of your workbook to the Forum to see -exactly- what you have there?...
 
Upvote 0
Cell Formulas
RangeFormula
A2:A12A2='raw daily'!B2
B2:B12B2='raw daily'!E2
C2:C12C2='raw daily'!I2
 
Upvote 0
In the cells of the columns A:C you can see (top left) some red "dots", right?...
Those are the way that XL2BB signifies the cell contains a formula.
 
Upvote 0
Those are the way that XL2BB signifies the cell contains a formula.

I understand, thank you.
What happens is that the data referenced by the formulas of the 'daily raw' sheet are those that are in text.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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