+ Reply to Thread
Results 1 to 6 of 6

Updated YES!! another counting of unique entries:)

Hybrid View

2001jesper Updated YES!! another... 04-14-2013, 06:37 AM
nilem Re: YES!! another counting of... 04-14-2013, 07:11 AM
2001jesper Re: YES!! another counting of... 04-14-2013, 08:16 AM
2001jesper Re: Updated YES!! another... 04-14-2013, 01:12 PM
nilem Re: Updated YES!! another... 04-14-2013, 11:09 PM
FDibbins Re: Updated YES!! another... 04-15-2013, 12:01 AM
  1. #1
    Registered User
    Join Date
    11-05-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    61

    Lightbulb Updated YES!! another counting of unique entries:)

    Good morning everybody

    iam trying to create a counting of unique combination. Iam doing this using =IF(SUMPRODUCT(($A$5:$A7=A7)*($B$5:$B7=B7))>1;0;1) i.e this returns a 1 if the combination is unique and a 0 if it's a dublicate.

    I need the 1's and 0's in order to get ratios for further calculations

    This is normally not a problem, but this time i have 60.000 + lines and that makes excel crash.

    my previous experience with coding WBA's is just a little over 3 minutes, but iam very good at CRTL+C, CRTL + V

    I hope theres help out there, and i can offer a "like" as a trade

    Thx in advance
    Attached Files Attached Files
    Last edited by 2001jesper; 04-14-2013 at 12:55 PM.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: YES!! another counting of unique entries:)

    Hi 2001jesper,
    try it
    Sub ertert()
    Dim x, y(), i&
    x = Range("A5:D" & Cells(Rows.Count, 1).End(xlUp).Row).Value
    ReDim y(1 To UBound(x), 1 To 3)
    With CreateObject("Scripting.Dictionary")
        .CompareMode = 1
        For i = 1 To UBound(x)
            If .Exists(x(i, 1) & "~" & x(i, 2)) Then y(i, 1) = 0 Else y(i, 1) = 1: .Item(x(i, 1) & "~" & x(i, 2)) = Empty
            If .Exists(x(i, 1) & "~" & x(i, 3)) Then y(i, 2) = 0 Else y(i, 2) = 1: .Item(x(i, 1) & "~" & x(i, 3)) = Empty
            If .Exists(x(i, 1) & "~" & x(i, 4)) Then y(i, 3) = 0 Else y(i, 3) = 1: .Item(x(i, 1) & "~" & x(i, 4)) = Empty
        Next i
    End With
    Range("F5:H5").Resize(i - 1).Value = y()
    End Sub

  3. #3
    Registered User
    Join Date
    11-05-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: YES!! another counting of unique entries:)

    Thank you so much, it almost worked.

    But when i tested on large scale and copied to my main sheet, it showed the wrong results. It gave me 1's in the first row and then zero's in the Rest

    It seems to fail when all 4 input rows are the same / or russian sign are in - i dont know.

    I hope theres anyone out there who can tweak the code with a small fix, it will be very appriciated

    Thx in Advance
    Attached Files Attached Files
    Last edited by 2001jesper; 04-14-2013 at 01:11 PM.

  4. #4
    Registered User
    Join Date
    11-05-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Updated YES!! another counting of unique entries:)

    bump bump bump

  5. #5
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Updated YES!! another counting of unique entries:)

    Let's add tildes (not Russian sign )
    try it
    Sub ertert()
    Dim x, y(), i&
    x = Range("A5:D" & Cells(Rows.Count, 1).End(xlUp).Row).Value
    ReDim y(1 To UBound(x), 1 To 3)
    With CreateObject("Scripting.Dictionary")
        .CompareMode = 1
        For i = 1 To UBound(x)
            If .Exists(x(i, 1) & "~" & x(i, 2)) Then y(i, 1) = 0 Else y(i, 1) = 1: .Item(x(i, 1) & "~" & x(i, 2)) = Empty
            If .Exists(x(i, 1) & "~~" & x(i, 3)) Then y(i, 2) = 0 Else y(i, 2) = 1: .Item(x(i, 1) & "~~" & x(i, 3)) = Empty
            If .Exists(x(i, 1) & "~~~" & x(i, 4)) Then y(i, 3) = 0 Else y(i, 3) = 1: .Item(x(i, 1) & "~~~" & x(i, 4)) = Empty
        Next i
    End With
    Range("F5:H5").Resize(i - 1).Value = y()
    End Sub

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: Updated YES!! another counting of unique entries:)

    Hi

    Instead of your sumproduct formula, try this, copied down abd across...

    =IF(COUNTIFS($A$5:$A5,A5,$B$5:$B5,B5)>1,0,1)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1