+ Reply to Thread
Results 1 to 3 of 3

Stack varying length columns

  1. #1
    Registered User
    Join Date
    02-01-2012
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    65

    Stack varying length columns

    Alright guys I am re-posting this now that I have more of an idea of exactly what I want. I posted this earlier today but since then I have found a solution but was hoping someone here might be able to improve upon it. I would like to mention that I am trying to do this with formulas and not a macros.

    I have this spreadsheet with 5 columns (columns D-H) that I want to compile into 1 large column. Each of the 5 columns is 26 rows long and while there is a formula in every cell, there are only numbers in some of the rows. Each column has a different number of rows (always starting at the top) filled. I want to create a column (J in this case) that places each of the columns underneath the last, starting with the leftmost. The catch is that I don't want the blank spaces to be included in the column AND the 5 columns can change in size.

    So for this spreadsheet I want Column D8:D18 to show up in K8:K18 and then E8:E21 to show up immediately bellow that in K19:K32 etc.

    The spreadsheet I have attached has a solution, and it is correct. However, in order to solve it I had to create Column J which stacks all the columns on top of each other INCLUDING the blanks/0s and then I delete all the blanks and place the results in K. I am trying to eliminate the need for column J and go straight to column K.

    The equation I used for column J was: =IF(OFFSET(D$8,MOD(ROWS($D$8:$D8)-1,ROWS(D$8:D$33)),INT((ROWS($D$8:$D8)-1)/ROWS($D$8:D$33)))="",0,OFFSET(D$8,MOD(ROWS($D$8:$D8)-1,ROWS(D$8:D$33)),INT((ROWS($D$8:$D8)-1)/ROWS($D$8:D$33))))

    Currently the section in red is always equal to 26. In order to solve my problem (at least the method I have started) I need to make the red part change to be equal to the number of filled rows in each column, switching when it gets done with each section.

    My closest attempt was to use the formula shown in column M: =OFFSET(D$8,MOD(ROWS($D$8:$D8)-1,COUNT(D$8:D$33)),INT((ROWS($D$8:$D8)-1)/11))

    The problem with this equation is similar in that I could not come up with a way to change blue highlighted 11 (number of rows in the column with a value) to move over to the 14 in the next column when it came time. Instead this equation just places 11 rows of column E below column D and so forth.

    Someone in my last thread mentioned the INDIRECT() function but I have never used that and can't seem to find an application for it.

    Anything would be helpful. While nobody nailed it in my last thread, a lot of their ideas helped me get this far. Thanks guys.

    Excel Help.xls

  2. #2
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: Stack varying length columns

    One more try:
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    02-01-2012
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    65

    Re: Stack varying length columns

    Works great thanks. I would add =if(iserror(formula),"",formula) though just to get rid of REFs

+ 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