+ Reply to Thread
Results 1 to 3 of 3

Transpose Variable Amount of Columns in Range

  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    4

    Transpose Variable Amount of Columns in Range

    Hello,

    I have a range of data that is organised in rows, from which I require a certain selection of those rows, based on a cell's value, to be copied to another worksheet and rearranged in a particular fashion. Attached is an example data set illustrating the original format of the data, and the desired end result after rearranging.

    Refer to the attached worksheet for references made. Essentially, each row contains identification data (columns A:C), and a variable amount of result data (columns D:X, where X can be any number of columns from D). The result data are always paired in two columns named "i.d." and "str (MPa)" respectively. The subject data set will be the rows denoted with a "yes" in the 'results entered' column (C:C). This subject data set will then be copied to a new worksheet and rearranged.

    The paired columns of result data are to be transposed. So that is, the record for "BR01" (row 3) has 3 column pairs (i.e. 3 results), and when rearranged, the 3 column pairs are transposed. The outcome is the data for "BR01" is spread over 3 rows, with the identification data (columns A:C) duplicated for each of the rows where a result data was transposed. The next row from the subject data set, "BR02" (row 4) will then be copied directly below the last row from "BR01" on the new sheet and transposed the amount corresponding to the number of paired result columns, (i.e. 1), and then so on for "BR03" and "BR04". The row for "BR05" would be excluded from the copy and rearrange as it has no results entered.

    Key points to be considered:
    - only rows with results entered (column C:C) as "yes" are to be included
    - the number of paired results will vary
    - process of copying and transposing to be looped for as many rows included in subject data set (could be in the hundreds)

    Thank you in advance for your input.

    Cheers,
    Ronjay24
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Transpose Variable Amount of Columns in Range

    Hi,

    The following macro should work. It will put the results starting in column G of the Final Re Arranged sheet so that you can compare with your manual example. With the production environment data obviously change the G1 reference in the macro to A1 or wherever you want the table.

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    08-29-2012
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Transpose Variable Amount of Columns in Range

    Worked like a charm, thanks Richard.

+ 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