+ Reply to Thread
Results 1 to 12 of 12

Partially "transpose" rows with formula

  1. #1
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Partially "transpose" rows with formula

    Hi,
    I got stuck with a problem, I believe that it can be solved by using formulas, hope you know how . I have data in rows and I want to represent them partially in columns based on the value of some cells. the best way to explain this is by the example in the attached file.

    I hope to get help with this ...

    Thanks in advance
    //E_B
    Attached Files Attached Files

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Partially "transpose" rows with formula

    I wrote this little subroutine which can do it for you:

    Please Login or Register  to view this content.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Partially "transpose" rows with formula

    And here's an example. Whee!

    I came up with a way to transpose the left columns with nested LOOKUPS, but more than a hundred or so of them would bring your computer to its knees.

    So I'd say the VB route is much safer. And faster too.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Partially "transpose" rows with formula

    Thank you daffodil11, It works but I'd prefer to solve this by formulas. I tried a lot with IF and OFFSET but did not succeed, any idea how to do it without VBA?

    Moreover continue to copy the rows if it is run again, I want it to run only one time. i.e. to copy the rows only one time.

    Thanks
    Emma

  5. #5
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Partially "transpose" rows with formula

    Hi,

    please can you help me to get the macro to copy the ranges only one time. i.e. if I run the macro it should copy the rows and transpose the last 3 columns according to the criteria and if I run it again it should maybe copy them again over the same cells and not under them, appreciate your quick reply.

    Thanks
    //Emma

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Partially "transpose" rows with formula

    Quote Originally Posted by Emma_B View Post
    transpose the last 3 columns according to the criteria
    What criteria?

  7. #7
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Partially "transpose" rows with formula

    with criteria I mean the code it self, this part (If c <> "" Then) i.e. if there is a value in either "option1","option2" or "option3", what I need is that when I click the button "Run Macro" fist time it copies the rows into the range A14:Fn according to the values in the option columns F to H. this is working. BUT if I click the button again it is copying the range again under the copied cells. I want it to not copy them again or at least to copy them in the same cells that has been generated by the first click.

    //Emma

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Partially "transpose" rows with formula

    Here's a formula-based solution if you're interested.

    This solution assumes that the blanks in your source range are "genuine" blanks (and not e.g. the "" as a result of formulas in those cells).

    I'm putting the transposed results in columns J-O, from row 2 onwards, though obviously amend if you wish (though being careful to amend all references appropriately).

    Case: cell J2, array formula**:

    =IFERROR(INDEX($A$2:$A$6,MATCH(TRUE,MMULT(0+(ROW($A$2:$A$6)>=TRANSPOSE(ROW($A$2:$A$6))),SUBTOTAL(3,OFFSET($F$2:$H$2,ROW($A$2:$A$6)-MIN(ROW($A$2:$A$6)),,,)))>=ROWS($1:1),0)),"")

    Copy down until you start to get blanks for the results.

    Field1: cell K2, non-array:

    =IF($J2="","",INDEX($A$2:$H$6,MATCH($J2,$A$2:$A$6,0),MATCH(K$1,$A$1:$H$1,0)))

    Copy down as required and also a further three columns to the right to give results for Field2, Field3 and Field(n) (I don't know what this last means: if you are intending to suggest that you could have an unknown number of column's worth of data, then I'm afraid it's not clear. That would in any case require a more complicated solution.)

    Option: cell O2, non-array:

    =IF($J2="","",INDEX(INDEX($F$2:$H$6,MATCH($J2,$A$2:$A$6,0),),,COUNTIF($J$2:$J2,$J2)))

    Again, copy down as required.

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  9. #9
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Partially "transpose" rows with formula

    Hi XOR LX,
    It returns error for the "fields" values!.
    With Fn I mean that I could have more columns than I have in the example file, however, I know exactly how many columns.
    I put them in the file so you can see the result I got.

    Regards
    //E_B
    Attached Files Attached Files

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Partially "transpose" rows with formula

    You need to repeat the headers in K1:N1 precisely as they appear in B1:E1, since they are being used by the formula to obtain the relevant data.

    Regards

  11. #11
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Partially "transpose" rows with formula

    In reference to the message you sent me:

    To adjust the code, you can simply add in an extra line at the beginning to delete the copy to area so it's fresh every time.

    Range("A14:F999").ClearContents


    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Partially "transpose" rows with formula

    Works perfect. Many thanks

    /Emma

+ 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] Need formula transpose data in col."description"
    By Jhon Mustofa in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-08-2014, 07:19 PM
  2. Replies: 1
    Last Post: 02-04-2014, 08:43 PM
  3. Replies: 1
    Last Post: 09-21-2013, 03:18 AM
  4. Replies: 5
    Last Post: 10-12-2010, 06:46 AM
  5. [SOLVED] transpose the code from "rows" to "columns"
    By markx in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-21-2005, 05:05 AM

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