+ Reply to Thread
Results 1 to 16 of 16

Transpose Data (Column to Rows)

  1. #1
    Registered User
    Join Date
    06-14-2021
    Location
    America
    MS-Off Ver
    Microsoft Excel for Office 365 MSO
    Posts
    32

    Post Transpose Data (Column to Rows)

    Hi,

    Hope that an expert can help me out with this.

    I'm trying to transpose the data shown in the attached example; from a column (Ex:A2:A46) into rows (Ex:C2:Y3).

    Problem is that the number of rows being transposed is not a fixed number, only differentiating factor is that the it begins at a 6 digit number and ends in the cell before the next 6 digit number
    (Ex:A2:A23 is the data that'll be transposed into the first row & A24:A46 the second row).

    There a lot of data in the spreadsheet so if someone can help me with a VBA Macro that can automatically transpose the data, that'll help me a lot!!

    Thank you,
    Attached Files Attached Files
    Last edited by Maxpsb47; 06-17-2021 at 02:37 PM.

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Transpose Data (Column to Rows)

    Hi Maxpsb47 & welcome to the forum

    Try below code based on your sample file ...
    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  3. #3
    Registered User
    Join Date
    06-14-2021
    Location
    America
    MS-Off Ver
    Microsoft Excel for Office 365 MSO
    Posts
    32

    Re: Transpose Data (Column to Rows)

    Oh wow!! I think this should work just fine. I'll run this on my master worksheet and see how it turns out. Thanks, you are a life saver!!

  4. #4
    Registered User
    Join Date
    06-14-2021
    Location
    America
    MS-Off Ver
    Microsoft Excel for Office 365 MSO
    Posts
    32

    Unhappy Re: Transpose Data (Column to Rows)

    Hi nankw83,

    Thanks again for the quick response.

    Ran into a issue here, please refer attached example for more information.

    The macro is not picking up the 6 digit numbers consistently also it looks like data is being duplicated somehow.

    The attached picture shows a "Run-time error '1004': that popped up after I ran the macro.
    Attached Images Attached Images
    Attached Files Attached Files

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Transpose Data (Column to Rows)

    Here is an alternative solution using Power Query.

    File is attached. Here is the Mcode

    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

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

    Re: Transpose Data (Column to Rows)

    Please Login or Register  to view this content.

  7. #7
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Transpose Data (Column to Rows)

    Quote Originally Posted by Maxpsb47 View Post
    The macro is not picking up the 6 digit numbers consistently also it looks like data is being duplicated somehow.
    Try revised code below ...
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-14-2021
    Location
    America
    MS-Off Ver
    Microsoft Excel for Office 365 MSO
    Posts
    32

    Re: Transpose Data (Column to Rows)

    Hi jindon,

    Thanks for helping out.

    The macro works really quick and consistently although I did get an error message (refer to attachment) and it did not transpose all of my data.

    All I did was change (whats marked in red)

    x = Filter([transpose(if((isnumber(b1:b129903))*(len(b1:b129903)=6),row(1:129903)))], False, 0)
    Attached Images Attached Images

  9. #9
    Registered User
    Join Date
    06-14-2021
    Location
    America
    MS-Off Ver
    Microsoft Excel for Office 365 MSO
    Posts
    32

    Re: Transpose Data (Column to Rows)

    Hi nankw83,

    I really appreciate the reply.

    I did end up with another error message (refer attachment). The macro is definitely working more consistently but it stops midway.
    Attached Images Attached Images

  10. #10
    Registered User
    Join Date
    06-14-2021
    Location
    America
    MS-Off Ver
    Microsoft Excel for Office 365 MSO
    Posts
    32

    Re: Transpose Data (Column to Rows)

    Hi alansidman,

    Thanks for mentioning about Power Query, I learned something new here. The Mcode you sent ended up transposing everything into 1 single row. I will definitely mess around with Power Query more and see were all it might be applicable at work.

  11. #11
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Transpose Data (Column to Rows)

    Maxpsb47, what's the maximum number of items possible under each number. i.e. How many columns would be enough ?

    Edit: Try below code ...
    Please Login or Register  to view this content.
    Last edited by nankw83; 06-21-2021 at 11:34 AM. Reason: Added a code

  12. #12
    Registered User
    Join Date
    06-14-2021
    Location
    America
    MS-Off Ver
    Microsoft Excel for Office 365 MSO
    Posts
    32

    Re: Transpose Data (Column to Rows)

    nankw83, I can't say for sure since all of this data was exported from an pdf file but after using the marco the maximum columns i saw was 34

  13. #13
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Transpose Data (Column to Rows)

    In the code I posted in post #11, I am assuming maximum number of columns is 100 which you can change in the below line
    Please Login or Register  to view this content.
    So does the code work now ?

  14. #14
    Registered User
    Join Date
    06-14-2021
    Location
    America
    MS-Off Ver
    Microsoft Excel for Office 365 MSO
    Posts
    32

    Re: Transpose Data (Column to Rows)

    nankw83,

    This code works perfectly, thanks a lot for the help man. I just gotta clean up the data and make it more workable.

  15. #15
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Transpose Data (Column to Rows)

    Glad to help & thanks for the feedback

  16. #16
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Transpose Data (Column to Rows)

    thanks for the rep and feedback. If you are serious about learning PQ then the book, "M is for (Data) Monkey" by Ken Puls and Miguel Escobar.

+ 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] Transpose data from 1 column to rows
    By mukuljain99 in forum Excel General
    Replies: 5
    Last Post: 05-10-2020, 02:41 PM
  2. Transpose Column Data to Rows
    By paradise2sr in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-13-2019, 10:55 AM
  3. Transpose rows to column and insert new rows to fill in data
    By Apple Ling in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-24-2019, 04:02 AM
  4. [SOLVED] Please help Transpose data from column to rows
    By Excel-Newbe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2018, 09:43 AM
  5. Transpose Column Data to Rows?
    By kestefon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-19-2013, 07:52 PM
  6. Insert rows, transpose data from column in to rows, in steps
    By mchevalier in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2012, 08:14 PM
  7. [SOLVED] Transpose Data from a column to several rows
    By stansdl in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-30-2006, 05: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