+ Reply to Thread
Results 1 to 5 of 5

Arrange table by gathering data cells

  1. #1
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Arrange table by gathering data cells

    Hi,

    In the attached WB I managed to write some code (behind Sheet1) to change the Source table, itself, into the requested layout.

    My question is - could this be done by ONLY Worksheets functions - preferable without any helper column - if possible.

    Please note that all 4 columns data should be transported to the target table.

    The upper left cell of the target/new layout table can be put in cell G1 or in cell A15.

    Thanks, Elm
    Attached Files Attached Files
    Last edited by ElmerS; 06-29-2009 at 06:00 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Arrange table by gathering data cells

    Assuming each name appears 3 times

    G1:
    =INDEX($A$2:$A$10,1+(3*(ROWS(G$1:G1)-1)))
    copied down

    H1:
    =LOOKUP(REPT("Z",255),INDEX(B:B,MATCH($G1,$A:$A,0)):INDEX(B:B,MATCH($G1,$A:$A)))
    copied down and applied also to Column J

    I1:
    as above but replace REPT("Z",255) with 9.99999999999999E+307

  3. #3
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Arrange table by gathering data cells

    Thank you, DonkeOte,

    This is nice and answers the question in full.

    However, if I may:

    a) What can be changed, if any, in the first formula to cope with various amounts of First Names - some will appear more or less than 3 times ?
    b) I tried to replace the 3 "trios" - still ABC sorted - with:
    ADAM
    ADAM
    ADAM
    BENNI
    BENNI
    BENNI
    CHARLIE
    CHARLIE
    CHARLIE
    it continued to work fine, as expected.

    But, when I changed the sorting order to:
    ADAM
    ADAM
    ADAM
    CHARLIE
    CHARLIE
    CHARLIE
    BENNI
    BENNI
    BENNI

    The results were incorrect.

    Thanks, again, for your efforts and patient,

    Elm

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Arrange table by gathering data cells

    I will answer question 2 as it's important

    For the formulae to work as they are the data in A should be sorted in Ascending order - it makes life easier in truth - if this isn't viable you can work around it but I would advise sorting ABC.

    Re: question 1

    If willing to have G1 with a different formula to G2 you can set

    G1: =A2
    G2: =INDEX($A$2:$A$100,1+COUNTIF($A$2:$A$100,"<="&G1))
    (change ranges to suit)

  5. #5
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Arrange table by gathering data cells

    Well, this is a little bit more than perfect.

    Thank you so much, Elm
    Last edited by ElmerS; 06-30-2009 at 02:15 AM.

+ 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