+ Reply to Thread
Results 1 to 6 of 6

Listing numbers in one cell by person's name

  1. #1
    Forum Contributor
    Join Date
    10-15-2013
    Location
    Calgary, Alberta
    MS-Off Ver
    Excel 2007
    Posts
    218

    Listing numbers in one cell by person's name

    Hello,

    I have list of names that I would like to consolidate the information into a single line...

    Column A is numbers (1,2,3,4,5...)
    Column C is persons names (Ian, Margaret, Lisa, Ian, Vivian....)

    Looks like this
    A C
    1 Ian
    2 Margaret
    3 Lisa
    4 Ian
    5 Vivian

    Column M I have all the names possible. In Column N, I would like to add the text "Line X" and "comma's plus a space" between each match.. like this...

    M N
    Ian "Line 1, 4" <--- Comma with a space
    Margaret "Line 2" <--- No comma in the end
    Lisa "Line 3"
    Vivian "Line 5"
    John "(Blank)"


    Note: Added quotation marks because spacing looked weird once posted. Also, Add that is no matches to leave blank.

    Your help with this is much appreciated!

    Thanks,
    Last edited by JasonNeedsHelp; 03-29-2018 at 12:07 PM.

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Listing numbers in one cell by person's name

    This is better suited for VBA but since you posted in the "Excel Formulas & Functions" section, I'll have a go at it using formulas.

    Based on the layout described in post #1 (assuming that the data starts in row 1), you can use this to return all matches:
    O1 =IFERROR(INDEX($A:$A,SMALL(IF($C$1:$C$5=$M1,ROW($C$1:$C$5)),COLUMNS($A:A))),"") Ctrl Shift Enter
    Drag this formula through Q1 then down through row 5.

    Then, in N1, this will combine the matches into a single cell:
    =IF(O1="","","Line ")&O1&IF(P1="","",", ")&P1&IF(Q1="","",", ")&Q1
    Drag this formula down through row 5.

    If you have the TEXTJOIN function (Office 365 subscription or UDF), you can use this scale able formula in N1:
    =IF(O1="","","Line ")&TEXTJOIN(",",TRUE,O1:Q1)
    Dragged down through row 5.

    See attachment for clarification.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    10-15-2013
    Location
    Calgary, Alberta
    MS-Off Ver
    Excel 2007
    Posts
    218

    Re: Listing numbers in one cell by person's name

    Thanks 63falcondude,

    This did work, but I should had been more clear with my description as there are in-reality 100~200 lines. In my example I only illustrated 5... and that there maybe more then just two times the name would come up. Ie. Ian "Line 1, 4, 24, 36, 99... etc".

    I will mark as solved since your answer does work and move this question to "Excel Formulas & Functions" section as you indicated.

    Thanks!

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Listing numbers in one cell by person's name

    This probably would have been easier if I decided to do double loops, one for the names in column M and another for the names in column B. However, I was bound and determined to use the find command and figure out a way to keep it from going back to the top after finding the last occurrence of the name.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  5. #5
    Forum Contributor
    Join Date
    10-15-2013
    Location
    Calgary, Alberta
    MS-Off Ver
    Excel 2007
    Posts
    218

    Re: Listing numbers in one cell by person's name

    Quote Originally Posted by dflak View Post
    This probably would have been easier if I decided to do double loops, one for the names in column M and another for the names in column B. However, I was bound and determined to use the find command and figure out a way to keep it from going back to the top after finding the last occurrence of the name.
    Oh Great!
    But i'm not sure how this works. There doesn't seem to be a formula that I can move to my spreadsheet.

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Listing numbers in one cell by person's name

    I did it in VBA, the macro name is NameRows. You can access it through the View Ribbon and use the options to assign a control key shortcut.

    I chose to put the data into an Excel Table. The red lines should be changed to suit your setup.
    Please Login or Register  to view this content.

+ 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. [SOLVED] Listing Row Numbers
    By Johnny0811 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-21-2017, 04:47 AM
  2. VBA to convert person-to-event into person-person
    By LuckyStrike in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-07-2014, 02:34 PM
  3. [SOLVED] Listing even and odd numbers
    By szasz in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-26-2013, 02:31 PM
  4. Listing all combinations of 6 out of 10 numbers?
    By Faux Carnival in forum Excel General
    Replies: 4
    Last Post: 11-06-2010, 07:38 AM
  5. Listing possible combinations of numbers
    By Rgaherty in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-02-2010, 09:39 PM
  6. listing numbers in column
    By jgclickfind in forum Excel General
    Replies: 6
    Last Post: 05-20-2005, 04:22 PM
  7. Listing Numbers within Ranges
    By shternm in forum Excel General
    Replies: 0
    Last Post: 02-22-2005, 02:20 PM

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