+ Reply to Thread
Results 1 to 4 of 4

Mutiple Values per each Single ID - Need a horizontal list

  1. #1
    Registered User
    Join Date
    05-09-2011
    Location
    NJ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Mutiple Values per each Single ID - Need a horizontal list

    Hi,

    I have a large list, almost 2200 lines, of 4 letter company codes in column A with account numbers in column B. Each company can anywhere from 1 to 10 account numbers. Therefore, sometimes column A will have 1 company code with column B having 1 corresponding account number - or - column A could have the same company code 10 times with the corresponding account numbers in column B. I need to turn this into a a list containing the company code in column A and the corresponding account numbers in columns B,C,D,E etc. (Also could have all acount numbers in one cell in column B separated by spaces - that would work too). I have attached the file. Any ideas?
    Attached Files Attached Files
    Last edited by tombo222; 05-10-2011 at 01:47 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Mutiple Values per each Single ID - Need a horizontal list

    Try the following,

    In C2 add a formula:

    =IF(COUNTIFS(A$2:A2,A2,B$2:B2,B2)=1,A2&"_"&COUNTIF(C$1:C1,A2&"*")+1,"")

    copied down.

    then select Column A and go to Data and select Advanced from the Sort & Filter section.

    Select Copy to Another Location,

    Ensure List range is your column A range.

    Leave the Criteria range blank

    in the Copy to range, enter or select first cell of column to copy to... e.g. $F$1

    Check the Unique Records Only checkbox

    Then in G2 enter formula:

    =IFERROR(INDEX($B:$B,MATCH($F2&"_"&COLUMNS($A$1:A$1),$C:$C,0)),"")

    copy across 10 columns to cover all results and then copy down the list of unique items.
    Attached Files Attached Files
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Mutiple Values per each Single ID - Need a horizontal list

    tombo222,

    Welcome to the Excel Forum.


    Detach/open workbook ReorgData w1 A B wR AdvancedFilter Unique A B C plus - tombo222 - EF775326 - SDG13.xlsm and run macro ReorgData.

    The macro will create a new worksheet Results containing a unique list of SCAC codes in column A, and column B will contain the TRAC_ACCOUNT_NUMBERS with two spaces between each number if there are two or more, and columns C thru ? will contain all the numbers in their owrn column.


    To run the macro on another workbook, with your raw data in worksheet scac+COMPANY_TRAC_ACCOUNT:


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


    1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
    2. Open your workbook
    3. Press the keys ALT + F11 to open the Visual Basic Editor
    4. Press the keys ALT + I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
    7. Press the keys ALT + Q to exit the Editor, and return to Excel
    8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


    Please Login or Register  to view this content.

    Before you use the macro, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


    Then run the ReorgData macro.
    Last edited by stanleydgromjr; 05-09-2011 at 07:08 PM.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  4. #4
    Registered User
    Join Date
    05-09-2011
    Location
    NJ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Mutiple Values per each Single ID - Need a horizontal list

    Awesome! That definitely did the trick and definitely made life easy since I need to run this daily. Thanks

+ 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