+ Reply to Thread
Results 1 to 17 of 17

Reformat data - multiple Columns to rows

  1. #1
    Registered User
    Join Date
    09-21-2021
    Location
    Los Angeles
    MS-Off Ver
    365
    Posts
    87

    Reformat data - multiple Columns to rows

    Attached is a Sample of data as it currently exists and then how it is needed to be reformatted.

    Each Customer Name (Source Column A) has the potential to have data in 16 columns (Columns C:R)

    I need to instead have the data be potentially 16 rows for each customer. (But then if the data in row is blank, then to not show that data).

    The Outcome tab of the attached sheet would show how the layout would need to be formatted.

    So for example, the First name (ALL909) has data in 6 of the 16 columns. So there should only be 6 rows of data for ALL909 when it is finalized on the Outcome tab.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    08-27-2015
    Location
    Singapore
    MS-Off Ver
    Office 2010, Office 365
    Posts
    159

    Re: Reformat data - multiple Columns to rows

    try this code.

    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Reformat data - multiple Columns to rows

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

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,703

    Re: Reformat data - multiple Columns to rows

    Unpivot your data with Power Query

    Please Login or Register  to view this content.
    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Registered User
    Join Date
    09-21-2021
    Location
    Los Angeles
    MS-Off Ver
    365
    Posts
    87

    Re: Reformat data - multiple Columns to rows

    THANK YOU ALL!!!! I will play with these and let you know if I have any questions.

  6. #6
    Registered User
    Join Date
    09-21-2021
    Location
    Los Angeles
    MS-Off Ver
    365
    Posts
    87

    Re: Reformat data - multiple Columns to rows

    Quote Originally Posted by seercoven View Post
    try this code.

    Please Login or Register  to view this content.
    @Seercoven - When I try to run this code it provides an error surrounding the "Next i" command. If I try changing the "i" to an "a" it does not seem to pull through all of the needed info. Please advise.

  7. #7
    Forum Contributor
    Join Date
    08-27-2015
    Location
    Singapore
    MS-Off Ver
    Office 2010, Office 365
    Posts
    159

    Re: Reformat data - multiple Columns to rows

    you're right. typo on my side. Please see highlighted in red changes.

    Please Login or Register  to view this content.
    Last edited by seercoven; 11-08-2022 at 08:45 PM.

  8. #8
    Registered User
    Join Date
    09-21-2021
    Location
    Los Angeles
    MS-Off Ver
    365
    Posts
    87

    Re: Reformat data - multiple Columns to rows

    Quote Originally Posted by seercoven View Post
    you're right. typo on my side.

    Please Login or Register  to view this content.
    Thank you for this! Can you please explain why variables i and k do not need to be defined? Just trying to learn and grow.

    When I try to run this, code it also presents an error - i think surrounding i not being defined.
    Last edited by mfusfw; 11-08-2022 at 03:05 PM.

  9. #9
    Registered User
    Join Date
    09-21-2021
    Location
    Los Angeles
    MS-Off Ver
    365
    Posts
    87

    Re: Reformat data - multiple Columns to rows

    Quote Originally Posted by jindon View Post
    try
    Please Login or Register  to view this content.
    Jindon - This works really well and fast on the sample sheet. I was not expecting to have issues adapting the sample to what I needed to do for the live sheet. In reality the issue I am having is updating

    Please Login or Register  to view this content.
    My plan was to have essentially a vlookup in this column to look up against the value in B(n,3). How would I go about adapting that. The value would be different for each value in b(n,1), so it is dependent on all of that data.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Reformat data - multiple Columns to rows

    Impossible to even guess, so upload your workbook showing how you want it.

  11. #11
    Registered User
    Join Date
    09-21-2021
    Location
    Los Angeles
    MS-Off Ver
    365
    Posts
    87

    Re: Reformat data - multiple Columns to rows

    Quote Originally Posted by jindon View Post
    try
    Please Login or Register  to view this content.
    Hi Jindon,

    I just ran into something that was unexpected when you originally helped, and was wondering if there is a way to help with this as well?

    Attached is what the worksheet looks like with sample data - and what the Current and Desired Outcomes look like. I highlighted in Yellow where the changes occur in the two outcomes need to appear.

    Essentially, if the group names are the same - but the customer names different, then something different from normal would need to happen to Column B and Column G of the data.

    I did not create a new thread since this directly relates to what was being done before.



    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mfusfw; 11-30-2022 at 07:43 PM.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Reformat data - multiple Columns to rows

    How is the code related to your attached workbook?

    No sheet named "Total", "Import", so no idea.

  13. #13
    Registered User
    Join Date
    09-21-2021
    Location
    Los Angeles
    MS-Off Ver
    365
    Posts
    87

    Re: Reformat data - multiple Columns to rows

    Ahhh so sorry. The Attached workbook has the Macro in it with correct code

    So sorry again

    Please Login or Register  to view this content.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Reformat data - multiple Columns to rows

    See if I understand your requirement.
    This is a stand alone type so, shouldn't be called from your existsing code.
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    09-21-2021
    Location
    Los Angeles
    MS-Off Ver
    365
    Posts
    87

    Re: Reformat data - multiple Columns to rows

    Quote Originally Posted by jindon View Post
    See if I understand your requirement.
    This is a stand alone type so, shouldn't be called from your existsing code.
    Please Login or Register  to view this content.
    This is REALLLLLLLY CLOSE to what is needed. I have uploaded the file with the new code in it...

    On the Outcome Tab - G7:G11 is perfect. G12 would need to update to show as "MGMT FEE - 234 - BUF282" but instead it just grabs the same reference that same "MGMT FEE - 234 - BOI716" value. So it needs to pull that updated customer name to append to the Item field, if that makes sense?



    This is absolutely amazing, though, I cannot believe how fast it is!!!
    Attached Files Attached Files

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Reformat data - multiple Columns to rows

    Ahhh, try change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    09-21-2021
    Location
    Los Angeles
    MS-Off Ver
    365
    Posts
    87

    Re: Reformat data - multiple Columns to rows

    [post removed]
    Last edited by mfusfw; 12-11-2023 at 10:47 PM.

+ 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. Reformat data in different cells to two rows
    By KingTamo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-17-2017, 12:34 AM
  2. Replies: 9
    Last Post: 12-15-2013, 10:05 PM
  3. [SOLVED] Macro to Reformat Rows that contain date, dollar amounts, and other data
    By dean87 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-31-2013, 09:16 AM
  4. How can I reformat some rows into columns in Excel?
    By nijialagua in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2012, 02:20 PM
  5. How can I reformat some rows into columns in Excel?
    By nijialagua in forum Excel General
    Replies: 2
    Last Post: 07-23-2012, 12:38 PM
  6. Replies: 1
    Last Post: 12-21-2011, 01:50 PM
  7. [SOLVED] reformat columns to rows?
    By RickyDee in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-11-2005, 05:05 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