+ Reply to Thread
Results 1 to 13 of 13

Converting columns into rows with different values

  1. #1
    Registered User
    Join Date
    07-04-2022
    Location
    Toronto, Canada
    MS-Off Ver
    Office for Mac
    Posts
    7

    Post Converting columns into rows with different values

    I have a csv file with 16 columns.
    The first 10 are contact information, the last 6 are different phone numbers sometimes for the same contact.
    My objective is to create duplicates of the first 10 columns with the new 11th column representing one phone number from the last 6 columns.
    Attaching a sample csv

    Thank you
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,202

    Re: Converting columns into rows with different values

    Are 6 telephone numbers ALWAYS present?
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Registered User
    Join Date
    07-04-2022
    Location
    Toronto, Canada
    MS-Off Ver
    Office for Mac
    Posts
    7

    Re: Converting columns into rows with different values

    Not always 6 but there will be at least one number in one of the columns

  4. #4
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,292

    Re: Converting columns into rows with different values

    Power Query
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Czeslaw; 07-04-2022 at 11:15 AM.

  5. #5
    Registered User
    Join Date
    07-04-2022
    Location
    Toronto, Canada
    MS-Off Ver
    Office for Mac
    Posts
    7

    Re: Converting columns into rows with different values

    Not sure I follow! I've put before and after of what I'm trying to accomplish in the sample csv file

  6. #6
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,292

    Re: Converting columns into rows with different values

    Changed from csv to xlsx

  7. #7
    Registered User
    Join Date
    07-04-2022
    Location
    Toronto, Canada
    MS-Off Ver
    Office for Mac
    Posts
    7

    Re: Converting columns into rows with different values

    Sorry but this is not what I'm trying to accomplish

    I am looking to keep all values from A to J as is in their own columns (no merging)
    Value in column K should have only one phone number

    Please check the updated sample2 with “before”: what the original sheet was and “after” an example of what the result should look like.

    Thank you
    Attached Files Attached Files

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Converting columns into rows with different values

    Administrative Note:

    Members will tailor the solutions they offer to the version (NOT release number) of Office (Excel, NOT Windows) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your version is for Mac, please also state this. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Converting columns into rows with different values

    PowerQuery

    M Code:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    07-04-2022
    Location
    Toronto, Canada
    MS-Off Ver
    Office for Mac
    Posts
    7

    Re: Converting columns into rows with different values

    Thank you! This is exactly what I want

    I'm not a coder. Can you please advise how do I load or implement this code to my actual sheet?

  11. #11
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,563

    Re: Converting columns into rows with different values

    Follow steps 1 and 2 in the linked article to open Power Query: http://raw.youramys.com/wiki-https-t...c/ba-p/3359795
    Once opened (see step 3 in article) select the Advanced Editor.
    Replace the existing code by pasting the code from AliGW's post (#9) into Advanced Editor window.
    Select OK.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  12. #12
    Registered User
    Join Date
    07-04-2022
    Location
    Toronto, Canada
    MS-Off Ver
    Office for Mac
    Posts
    7

    Re: Converting columns into rows with different values

    I don't have power query as I'm using office for mac. Is there a formula to use directly in excel or google sheets instead of having the need to use power query?

  13. #13
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,563

    Re: Converting columns into rows with different values

    Here is a formula-based proposal.
    Populate cells Q4:Q6 using: =SUM(COUNTIFS(K4:P4,"<>"),Q3)
    Populate the First Name through Mail Zip columns using: =IFERROR(INDEX(A$4:A$6,AGGREGATE(15,6,(ROW(A$4:A$6)-ROW(A$3))/($Q$4:$Q$6>=ROWS(N$15:N15)),1)),"")
    Populate the Phone column using: =IFERROR(AGGREGATE(15,6,K$4:P$6/(K$4:P$6<>"")/(A$4:A$6=N15)/(B$4:B$6=O15),COUNTIFS(A$15:A15,A15)),"")
    Let us know if you have any questions.
    Attached Files Attached Files

+ 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] Converting Formulae to Values, Deleting Rows, Columns and Sheets using VBA
    By andrewc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-06-2021, 02:19 AM
  2. Converting rows to columns and adding extra rows as required
    By teco in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-09-2016, 04:18 PM
  3. Converting multiple columns to rows / Converting to Panel Data
    By Stuart11 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-14-2013, 05:50 AM
  4. Converting columns to rows for multiple rows
    By khscruz in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-04-2011, 11:59 AM
  5. Converting rows to columns
    By RTownley in forum Excel General
    Replies: 10
    Last Post: 06-09-2010, 01:34 AM
  6. (Again) Converting rows to columns
    By nickr1954 in forum Excel General
    Replies: 4
    Last Post: 01-28-2006, 09:25 AM
  7. Re: (Again) Converting rows to columns
    By Barb Reinhardt in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2006, 06:45 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