macros to find duplicates count in new sheet

Important Notice


Please note that on 14th December 2023 users will experience an expected outage whilst we make upgrades to our network. We anticipate this process may take a couple of hours and so we apologise in advance for any inconvenience.

  • I am trying to find the number of same values are repeated in particular column. Then I need to paste the value and the count of the repeated value in column A,B,C,D of another sheet. I need to count the number of times repeated values: data is like below... [TABLE="border: 0, cellpadding: 0, cellspacing: 0, width: 179"]

    [tr]


    [td]

    Data1

    [/td]


    [td]

    Data2

    [/td]


    [td]

    Data3

    [/td]


    [td]

    Data4

    [/td]


    [/tr]


    [tr]


    [td]

    D1

    [/td]


    [td]

    D3

    [/td]


    [td]

    D1

    [/td]


    [td]

    D1

    [/td]


    [/tr]


    [tr]


    [td]

    D1

    [/td]


    [td]

    D3

    [/td]


    [td]

    D1

    [/td]


    [td]

    D1

    [/td]


    [/tr]


    [tr]


    [td]

    D1

    [/td]


    [td]

    D2

    [/td]


    [td]

    D1

    [/td]


    [td]

    D3

    [/td]


    [/tr]


    [tr]


    [td]

    D2

    [/td]


    [td]

    D2

    [/td]


    [td]

    D3

    [/td]


    [td]

    D3

    [/td]


    [/tr]


    [tr]


    [td]

    D2

    [/td]


    [td]

    D3

    [/td]


    [td]

    D2

    [/td]


    [td]

    D5

    [/td]


    [/tr]


    [tr]


    [td]

    D3

    [/td]


    [td]

    D1

    [/td]


    [td]

    D1

    [/td]


    [td]

    D3

    [/td]


    [/tr]


    [tr]


    [td]

    D3

    [/td]


    [td]

    D2

    [/td]


    [td]

    D1

    [/td]


    [td]

    D1

    [/td]


    [/tr]


    [tr]


    [td]

    D3

    [/td]


    [td]

    D2

    [/td]


    [td]

    D1

    [/td]


    [td]

    D3

    [/td]


    [/tr]


    [tr]


    [td]

    D3

    [/td]


    [td]

    D3

    [/td]


    [td]

    D3

    [/td]


    [td]

    D3

    [/td]


    [/tr]


    [tr]


    [td]

    D3

    [/td]


    [td]

    D3

    [/td]


    [td]

    D1

    [/td]


    [td]

    D3

    [/td]


    [/tr]


    [/TABLE]



    and result should get like below [TABLE="border: 0, cellpadding: 0, cellspacing: 0, width: 227"]

    [tr]


    [td]

    Data

    [/td]


    [td]

    Count1

    [/td]


    [td]

    Count1

    [/td]


    [td]

    Count3

    [/td]


    [td]

    Count4

    [/td]


    [/tr]


    [tr]


    [td]

    D1

    [/td]


    [td]

    3

    [/td]


    [td]

    1

    [/td]


    [td]

    7

    [/td]


    [td]

    3

    [/td]


    [/tr]


    [tr]


    [td]

    D2

    [/td]


    [td]

    2

    [/td]


    [td]

    4

    [/td]


    [td]

    1

    [/td]


    [td]

    0

    [/td]


    [/tr]


    [tr]


    [td]

    D3

    [/td]


    [td]

    5

    [/td]


    [td]

    5

    [/td]


    [td]

    2

    [/td]


    [td]

    6

    [/td]


    [/tr]


    [tr]


    [td]

    D5

    [/td]


    [td]

    0

    [/td]


    [td]

    0

    [/td]


    [td]

    0

    [/td]


    [td]

    1

    [/td]


    [/tr]


    [/TABLE]

  • Perhab like this

  • Try again untest

  • Hi Dude,


    after run above the above macro excel get crashed..
    after several minutes finally in my hand got the 0 count
    [TABLE="border: 0, cellpadding: 0, cellspacing: 0, width: 240"]

    [tr]


    [TD="width: 64, bgcolor: transparent"]D1[/TD]
    [TD="width: 64, bgcolor: transparent, align: right"]0[/TD]
    [TD="width: 64, bgcolor: transparent, align: right"]0[/TD]
    [TD="width: 64, bgcolor: transparent, align: right"]0[/TD]
    [TD="width: 64, bgcolor: transparent, align: right"]0[/TD]

    [/tr]


    [tr]


    [TD="bgcolor: transparent"]D3[/TD]
    [TD="bgcolor: transparent, align: right"]0[/TD]
    [TD="bgcolor: transparent, align: right"]0[/TD]
    [TD="bgcolor: transparent, align: right"]0[/TD]
    [TD="bgcolor: transparent, align: right"]0[/TD]

    [/tr]


    [tr]


    [TD="bgcolor: transparent"]D2[/TD]
    [TD="bgcolor: transparent, align: right"]0[/TD]
    [TD="bgcolor: transparent, align: right"]0[/TD]
    [TD="bgcolor: transparent, align: right"]0[/TD]
    [TD="bgcolor: transparent, align: right"]0[/TD]

    [/tr]


    [tr]


    [TD="bgcolor: transparent"]D5[/TD]
    [TD="bgcolor: transparent, align: right"]0[/TD]
    [TD="bgcolor: transparent, align: right"]0[/TD]
    [TD="bgcolor: transparent, align: right"]0[/TD]
    [TD="bgcolor: transparent, align: right"]0[/TD]

    [/tr]


    [/TABLE]

    and the formula pasted till row (1048576)..

  • I found the below function on other forum.. but it working only for the a single column ..
    please can you work on it and take all our 4 column in data and result as we want


    also if possible each criteria count and data name can I have In variable like ...below


    dim strm1,strm2,strm3,strm4 as string
    dim vlu1, vlu2,vlu3......till vlu16 as long


    so I can position them as I want..


    thanks for your help...




    Sub naya()


    Summarize Sheet1.Range("A2:A9"), Sheet1.Range("C1")


    End Sub


    Function Summarize(rngSource As Range, rngTarget As Range)


    Dim rng As Range
    Dim var As Variant
    Set d = CreateObject("Scripting.Dictionary")
    For Each rng In rngSource
    If rng <> "" Then
    If d.Exists(rng.Value) Then
    d(rng.Value) = d(rng.Value) + 1
    Else
    d.Add rng.Value, 1
    End If
    End If
    Next rng


    rngTarget = "Value"
    rngTarget.Offset(, 1) = "Count"
    Set rng = rngTarget.Offset(1)
    For Each var In d.Keys
    rng = var
    rng.Offset(, 1) = d(var)
    Set rng = rng.Offset(1)
    Next
    End Function

  • yes dude appreciate....awesome your work.. .huge clap for you....


    just final request can I get all output into variable, as m working on a project so I can store the value each criteria each position where I want.....

  • Rmrekoj try this i am has test and work

  • and if you want to another sheet

  • Thanks for your Thanks ..AND for the Like... :smile:



    with the help of your vba I got new challenge below m working on that ,,...



    Data is like ....date column will be filtered many criteria I have done work on that I just wanted to work after special cells


    this is filtered data with some criteria and visible like below
    [TABLE="border: 0, cellpadding: 0, cellspacing: 0, width: 164"]

    [tr]


    [td]

    Date

    [/td]


    [td]

    Data1

    [/td]


    [td]

    Data2

    [/td]


    [/tr]


    [tr]


    [td]

    A

    [/td]


    [td]

    D1

    [/td]


    [td]

    D3

    [/td]


    [/tr]


    [tr]


    [td]

    B

    [/td]


    [td]

    D1

    [/td]


    [td]

    D3

    [/td]


    [/tr]


    [tr]


    [td]

    B

    [/td]


    [td]

    D1

    [/td]


    [td]

    D2

    [/td]


    [/tr]


    [tr]


    [td]

    A

    [/td]


    [td]

    D2

    [/td]


    [td]

    D2

    [/td]


    [/tr]


    [tr]


    [td]

    B

    [/td]


    [td]

    D2

    [/td]


    [td]

    D3

    [/td]


    [/tr]


    [tr]


    [td]

    A

    [/td]


    [td]

    D3

    [/td]


    [td]

    D1

    [/td]


    [/tr]


    [tr]


    [td]

    A

    [/td]


    [td]

    D3

    [/td]


    [td]

    D2

    [/td]


    [/tr]


    [tr]


    [td]

    B

    [/td]


    [td]

    D3

    [/td]


    [td]

    D2

    [/td]


    [/tr]


    [tr]


    [td]

    A

    [/td]


    [td]

    D3

    [/td]


    [td]

    D3

    [/td]


    [/tr]


    [tr]


    [td]

    B

    [/td]


    [td]

    D3

    [/td]


    [td]

    D3

    [/td]


    [/tr]


    [/TABLE]


    and output need


    [TABLE="border: 0, cellpadding: 0, cellspacing: 0, width: 229"]

    [tr]


    [td][/td]


    [td]

    A

    [/td]


    [td][/td]


    [td][/td]


    [td]

    B

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    Unique

    [/td]


    [td]

    Col1

    [/td]


    [td]

    Col2

    [/td]


    [td][/td]


    [td]

    Col1

    [/td]


    [td]

    Col2

    [/td]


    [/tr]


    [tr]


    [td]

    D1

    [/td]


    [td]

    1

    [/td]


    [td]

    1

    [/td]


    [td][/td]


    [td]

    2

    [/td]


    [td]

    0

    [/td]


    [/tr]


    [tr]


    [td]

    D3

    [/td]


    [td]

    1

    [/td]


    [td]

    2

    [/td]


    [td][/td]


    [td]

    1

    [/td]


    [td]

    3

    [/td]


    [/tr]


    [tr]


    [td]

    D2

    [/td]


    [td]

    3

    [/td]


    [td]

    2

    [/td]


    [td][/td]


    [td]

    2

    [/td]


    [td]

    2

    [/td]


    [/tr]


    [/TABLE]

  • and if you want to another sheet


    thanks for answer.
    I learn it

  • Hi team,


    this is working in excel how to use in vba


    =SUMPRODUCT(SUBTOTAL(3,OFFSET(B2:B50,ROW(B2:B50)-MIN(ROW(B2:B50)),,1))*(B2:B50="A1"))



    Thanks

  • if you want new case should be make new treat
    try this and if this you want

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!