+ Reply to Thread
Results 1 to 18 of 18

How to interchange cell values with column names in a data table in Excel

  1. #1
    Registered User
    Join Date
    12-21-2021
    Location
    New Delhi, India
    MS-Off Ver
    2019
    Posts
    8

    How to interchange cell values with column names in a data table in Excel

    I have following data of 3 persons posted at 3 places on 3 days of the week:

    JRb8L.png
    Please Login or Register  to view this content.
    I want to convert above data to following table format:

    prk2Z.png
    Please Login or Register  to view this content.
    The cells of new table should get filled automatically using data in first table.

    How can this be done?
    Last edited by rnexcel; 12-21-2021 at 01:20 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: How to interchange cell values with column names in a data table in Excel

    When asking a question and you have some sample data, it is always better to attach an actual Excel file instead of just pictures of your data. That way we can modify your file without having to create one from scratch. Put the formula in the upper left corner of the destination table and fill across and down to fill the table.

    Values as displayed
    A
    B
    C
    D
    E
    F
    G
    H
    I
    1
    Original
    Solution
    2
    Tom
    Dik
    Harry
    Cafe
    Library
    Gym
    3
    Monday
    Cafe
    Library
    Gym
    Monday
    Tom
    Dik
    Harry
    4
    Tuesday
    Library
    Gym
    Cafe
    Tuesday
    Harry
    Tom
    Dik
    5
    Wednesday
    Gym
    Cafe
    Library
    Wednesday
    Dik
    Harry
    Tom
    Underlying formulas
    A
    B
    C
    D
    E
    F
    G
    H
    I
    1
    Original
    Solution
    2
    Tom
    Dik
    Harry
    Cafe
    Library
    Gym
    3
    Monday
    Cafe
    Library
    Gym
    Monday
    =INDEX($B$2:$D$2,1,MATCH(G$2,$B3:$D3,0))
    =INDEX($B$2:$D$2,1,MATCH(H$2,$B3:$D3,0))
    =INDEX($B$2:$D$2,1,MATCH(I$2,$B3:$D3,0))
    4
    Tuesday
    Library
    Gym
    Cafe
    Tuesday
    =INDEX($B$2:$D$2,1,MATCH(G$2,$B4:$D4,0))
    =INDEX($B$2:$D$2,1,MATCH(H$2,$B4:$D4,0))
    =INDEX($B$2:$D$2,1,MATCH(I$2,$B4:$D4,0))
    5
    Wednesday
    Gym
    Cafe
    Library
    Wednesday
    =INDEX($B$2:$D$2,1,MATCH(G$2,$B5:$D5,0))
    =INDEX($B$2:$D$2,1,MATCH(H$2,$B5:$D5,0))
    =INDEX($B$2:$D$2,1,MATCH(I$2,$B5:$D5,0))
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: How to interchange cell values with column names in a data table in Excel

    sorry, wrong post
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  4. #4
    Registered User
    Join Date
    12-21-2021
    Location
    New Delhi, India
    MS-Off Ver
    2019
    Posts
    8

    Re: How to interchange cell values with column names in a data table in Excel

    6StringJazzer :

    Thanks for informing that Excel file should have been added.

    Thanks also for your answer. This is exactly what I wanted.
    Will it work, if there is duplication of persons or site/location?

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,064

    Re: How to interchange cell values with column names in a data table in Excel

    Provide a sample workbook illustrating this extension problem.

    There are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: How to interchange cell values with column names in a data table in Excel

    Quote Originally Posted by rnexcel View Post
    Will it work, if there is duplication of persons or site/location?
    If the row with names has the same name more than once, you will only get the entry under the first occurrence.

    If your data is more complicated than what you showed then you will need to provide a sample file.

  7. #7
    Registered User
    Join Date
    12-21-2021
    Location
    New Delhi, India
    MS-Off Ver
    2019
    Posts
    8

    Re: How to interchange cell values with column names in a data table in Excel

    Can pivot table or some similar technique work for this?

    (I tried to add an Excel file as attachment but cannot add it to first or this post).
    Last edited by rnexcel; 12-23-2021 at 09:08 AM.

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,035

    Re: How to interchange cell values with column names in a data table in Excel

    If you tried to use the paperclip icon, it doesn't work.
    Please click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window as stated in the banner at the top of the page.
    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.

  9. #9
    Registered User
    Join Date
    12-21-2021
    Location
    New Delhi, India
    MS-Off Ver
    2019
    Posts
    8

    Re: How to interchange cell values with column names in a data table in Excel

    I have managed to attach an xls file for this question:
    Attached Files Attached Files

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,064

    Re: How to interchange cell values with column names in a data table in Excel

    Why the old .xls format? You are using a much newer version, so you can attach an .xlsx file that everyone can open.

  11. #11
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,035

    Re: How to interchange cell values with column names in a data table in Excel

    (From post #4) Will it work, if there is duplication of persons or site/location?
    Glad that you were able to upload a file, however it doesn't illustrate the issue about which you asked above.
    That said, to fill the output in the file paste the following modification of Jeff's formula into cell C14 and drag over and down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.

  12. #12
    Registered User
    Join Date
    12-21-2021
    Location
    New Delhi, India
    MS-Off Ver
    2019
    Posts
    8

    Re: How to interchange cell values with column names in a data table in Excel

    Yes, the formula works well:
    Attached Files Attached Files
    Last edited by AliGW; 12-29-2021 at 08:02 AM. Reason: PLEASE don't quote unnecessarily!

  13. #13
    Registered User
    Join Date
    12-21-2021
    Location
    New Delhi, India
    MS-Off Ver
    2019
    Posts
    8

    Re: How to interchange cell values with column names in a data table in Excel

    Quote Originally Posted by AliGW View Post
    Why the old .xls format? You are using a much newer version, so you can attach an .xlsx file that everyone can open.
    What is the main advantage of xlsx over xls? Can newer version not open xls format?

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,064

    Re: How to interchange cell values with column names in a data table in Excel

    The .xls format will not open automatically for forum members when attached here - that's the main problem for us. For you, you will no doubt find that the .xls format will limit what is supported. If you are using Excel 2019, then you should be saving everything in .xlsx format.

  15. #15
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,035

    Re: How to interchange cell values with column names in a data table in Excel

    (From post #12) Yes, the formula works well
    Thank You for the feedback. Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. I hope that you have a blessed day.

  16. #16
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: How to interchange cell values with column names in a data table in Excel

    Quote Originally Posted by AliGW View Post
    The .xls format will not open automatically for forum members when attached here
    I don't have that problem. The .xls files (including the one above) pop open right away for me.

    Quote Originally Posted by rnexcel
    What is the main advantage of xlsx over xls? Can newer version not open xls format?
    The format changed starting with Excel 2007. That was 14 years ago. Very few people still use versions older than that. Therefore anybody who edits your .xls file may be using features that not supported by .xls, such as newer conditional formatting features. You will have the same problem yourself if you are using Excel 2019. You should always use the .xlsx format, and not .xls.

  17. #17
    Registered User
    Join Date
    12-21-2021
    Location
    New Delhi, India
    MS-Off Ver
    2019
    Posts
    8

    Re: How to interchange cell values with column names in a data table in Excel

    Quote Originally Posted by JeteMc View Post
    Thank You for the feedback. Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. I hope that you have a blessed day.
    Thanks for reminding. Thread marked as solved.

  18. #18
    Registered User
    Join Date
    12-21-2021
    Location
    New Delhi, India
    MS-Off Ver
    2019
    Posts
    8

    Re: How to interchange cell values with column names in a data table in Excel

    Quote Originally Posted by 6StringJazzer View Post
    I don't have that problem. The .xls files (including the one above) pop open right away for me.

    The format changed starting with Excel 2007. That was 14 years ago. Very few people still use versions older than that. Therefore anybody who edits your .xls file may be using features that not supported by .xls, such as newer conditional formatting features. You will have the same problem yourself if you are using Excel 2019. You should always use the .xlsx format, and not .xls.
    One feature I noticed in our workplace is that doc format opens well with LibreOffice on Linux while docx sometimes shows errors. Using xls emanated from that. I agree that is not really a valid reason for using doc or xls formats.

+ 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] Looping throuhg sheets to interchange values
    By EverGreen1231 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-29-2014, 09:46 AM
  2. Data from one column to another - Matching names and values (complex)
    By fetow in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-12-2014, 11:38 PM
  3. How to fetch first few values or names from excel column
    By meetvivek72 in forum Excel General
    Replies: 5
    Last Post: 02-13-2014, 06:48 AM
  4. need excel formula to get result from data table depends upon week,partner,column values
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2013, 08:41 AM
  5. Writing to cell in table based on column and row names
    By teacher_rob in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-09-2011, 11:17 PM
  6. Interchange symbols in a column
    By kamalthakur in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2010, 04:15 AM
  7. How do I have a data table display cell names rather than values?
    By raortiz99 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-09-2005, 12:15 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