+ Reply to Thread
Results 1 to 7 of 7

Excel formula - list numbers for unique entries

  1. #1
    Forum Contributor
    Join Date
    08-23-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    139

    Excel formula - list numbers for unique entries

    Hi everyone, I think my question will have an easy answer. I have a list of items in colA, to row 23000. In order to run analysis I need to find a way to assign a number to each item in the list, but duplicate items need to show the same ID number.

    The list is currently unsorted, and contains text, numbers, and mixed cells formatted as "general".

    Thanks in advance, i'm happy to provide extra detail if needed.
    IF("helping me", "thanks", "need more detail?")

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Excel formula - list numbers for unique entries

    You can try this formula but it will work on a sorted column only and without blanks.

    In B1 and copy down

    =SUMPRODUCT(1/COUNTIF(A$1:A1,A$1:A1))


    Row\Col
    A
    B
    1
    Item1
    1
    2
    unsorted
    2
    3
    Item2
    3
    4
    Item2
    3
    5
    contains text
    4
    6
    Item3
    5
    7
    Item3
    5
    8
    numbers
    6
    9
    numbers
    6
    10
    Item5
    7
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Excel formula - list numbers for unique entries

    Quote Originally Posted by AlKey View Post
    You can try this formula but it will work on a sorted column only and without blanks.
    Didn't try your formula, but you said column must be sorted yet your demo table column A is not...???

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Excel formula - list numbers for unique entries

    @jhren

    I meant sorted in the sense that duplicates must be together but not necessarily in alphabetical order although it would be fine too.

  5. #5
    Forum Contributor
    Join Date
    08-23-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: Excel formula - list numbers for unique entries

    Ah, sumproduct. I knew there was an easy way but don't use sumproduct very often so it didn't even cross my mind.

    I can sort the range no problem so this solution will work for me (i'm writing this while it is untested, but just looking at the formula and your example i know it would be perfect).

    I see stars in your future Mr. AlKey

    ** Note to all future people who come to this thread from Google (or whatever future-magic brings you here) - The solution in this thread will work for what you need, but the Sumproduct function is slow when you use it like this on a large range. Mine is c.23000 rows, so will take a while to calculate on my puny quad core i5 processor. This is fine for my own purpose because once it has run I will paste values and never need it again but obviously, leaving the formulas in and changing the data will result in long waiting times - unless of course you live a future where the quantum computer is a real thing, in which case disregard this and resume your life :D **
    Last edited by jayherring86; 05-20-2015 at 09:16 PM.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Excel formula - list numbers for unique entries

    This should calculate much faster...

    Data Range
    A
    B
    1
    Header
    Header
    2
    Item1
    1
    3
    unsorted
    2
    4
    Item2
    3
    5
    Item2
    3
    6
    contains text
    4
    7
    Item3
    5
    8
    Item3
    5
    9
    numbers
    6
    10
    numbers
    6
    11
    Item5
    7


    Enter 1 in B2

    Enter this formula in B3 and copy down as needed:

    =IF(A3=A2,B2,B2+1)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Excel formula - list numbers for unique entries

    P.S.

    On 23k rows of data this is how many cells are being evaluated using the SUMPRODUCT/COUNTIF formula:

    =SUMPRODUCT(ROW(A1:A23000))


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Create dropdown list in Excel that will only list unique entries
    By MissAudrey in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 01-22-2015, 04:56 PM
  2. [SOLVED] Formula (array?) to list unique entries that match criteria?
    By Rerock in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 11-11-2014, 04:23 PM
  3. Excel Function to Generate list of unique entries from multiple columns
    By ronnycool in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-16-2014, 06:15 PM
  4. Replies: 1
    Last Post: 05-30-2012, 06:29 AM
  5. Using VBA: I have a list with multiple entries.Need to reduce down to unique entries
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-25-2011, 03:19 PM

Tags for this Thread

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