+ Reply to Thread
Results 1 to 7 of 7

Build an Array

  1. #1
    Forum Contributor Lotus123's Avatar
    Join Date
    11-07-2005
    Location
    Texas
    MS-Off Ver
    2007
    Posts
    153

    Build an Array

    Okay, I'm having a brain fart here and cannot seem to build the right array here:

    Contents of cells A1:F1...
    10,-5,-2,-1,-3,-5

    I want to build an array that has these values in it
    10,5,3,2,-1,-6

    The above numbers are the SUM of all cells preceeding. I will then use an IF function on the array to find the value that is closest to zero without going under...or in this case, 2.

    Thanks!
    Ecce Potestas Casei
    Nathan Head

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    You could put this in A2 and drag across:

    =SUM($A$1:A1)

    Then this array formula for the smallest >0

    =MIN(IF(A2:F2>0,A2:F2))

  3. #3
    Forum Contributor Lotus123's Avatar
    Join Date
    11-07-2005
    Location
    Texas
    MS-Off Ver
    2007
    Posts
    153
    Of course, but the point is I'm attempting to expand my array writing capabilities. I want to do this all on one formula .

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Lordy, now you're asking. No doubt it can but I'm a bit rubbish at those complicated formulae.

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by Lotus123
    Okay, I'm having a brain fart here and cannot seem to build the right array here:

    Contents of cells A1:F1...
    10,-5,-2,-1,-3,-5

    I want to build an array that has these values in it
    10,5,3,2,-1,-6

    The above numbers are the SUM of all cells preceeding. I will then use an IF function on the array to find the value that is closest to zero without going under...or in this case, 2.

    Thanks!
    Try:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER.... adjust ranges to suit.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Here's one way

    =MIN(IF(SUBTOTAL(9,OFFSET(A1,,,,COLUMN(A1:F1)))>0,SUBTOTAL(9,OFFSET(A1,,,,COLUMN(A1:F1)))))

    confirmed with CTRL+SHIFT+ENTER

  7. #7
    Forum Contributor Lotus123's Avatar
    Join Date
    11-07-2005
    Location
    Texas
    MS-Off Ver
    2007
    Posts
    153
    Thanks everyone - what I learned: I need to use SUBTOTAL a little more in my array formulas; it appears to work much better.

+ 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