+ Reply to Thread
Results 1 to 17 of 17

Excel 365: How to put a MAX function into an array?

  1. #1
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2409
    Posts
    207

    Excel 365: How to put a MAX function into an array?

    Hi, I want to do a simple MAX function for all the values per row (simple enough), but I don't know the syntax for putting this into an array for multiple rows. I'm using Excel 365, so the ability to just enter this in one cell would be great. Any pointers appreciated. TIA, Paul

  2. #2
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Excel 365: How to put a MAX function into an array?

    =SUBTOTAL(4,OFFSET(D14#,,,SEQUENCE(ROWS(D14#))))

    This should fill down and give the max value of each row

    D14# is whatever array you're trying to reference

    edit: shoot...I just noted it doesn't work as the range is expanding and not just taking one row at a time
    maybe this is a starting point and someone else got another idea :/
    Last edited by RaulSerg; 10-17-2021 at 01:14 PM.

  3. #3
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Excel 365: How to put a MAX function into an array?

    @paulma1960, please try this:

    =SUBTOTAL(4,OFFSET(B2#,SEQUENCE(ROWS(B2#),,0,1),,1))

    B2# being your referenced array

    btw - to my knowledge there's no way via MAX to achieve the same result; neither to replace OFFSET with a non-volatile INDEX-alternative; at least I haven't figured one out yet, but happy to be shown otherwise!

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

    Re: Excel 365: How to put a MAX function into an array?

    RaulSerg is correct. If and when the BYROW function becomes available (currently only for Office Insiders), then we'll have a non-volatile alternative:

    =BYROW(B2#,LAMBDA(x,MAX(x)))

    Regards
    Click * below if this answer helped

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

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

    Re: Excel 365: How to put a MAX function into an array?

    Ah, wait, we can use constructions such as:

    =MOD(LARGE(10^6*ROW(B2#)+B2#,SEQUENCE(ROWS(B2#),,COUNT(B2#)-COLUMNS(B2#)+1,-COLUMNS(B2#))),10^6)

    That's just an example. I'm sure the SEQUENCE part can be abbreviated considerably.

    Though of course this set-up is rather artificial and not sound for a range containing large values.

    Regards
    Last edited by XOR LX; 10-17-2021 at 04:13 PM.

  6. #6
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Excel 365: How to put a MAX function into an array?

    Nice idea.

  7. #7
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2409
    Posts
    207

    Re: Excel 365: How to put a MAX function into an array?

    Thanks, RaulSerg. That's brilliant, and works a treat without any probs.

    Just another question, how can I emulate a MAX function on two columns, per row. ie, I want the MAX of two values in the same row, and then spill into an array down the column? TIA, Paul

  8. #8
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Excel 365: How to put a MAX function into an array?

    Hmm, how is that not the same question as before?

    If you mean that columns 1 and 2 are not an array that can be referenced with the #-operator, it defeats slightly the spilling idea, but I believe the underlying principle is the same.

    Pls see the example attached.
    Pls correct me if I have not understood correctly.

    Regards
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2409
    Posts
    207

    Re: Excel 365: How to put a MAX function into an array?

    The values are in the same row, but the columns aren't contiguous.

  10. #10
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Excel 365: How to put a MAX function into an array?

    Is it a continuous range or are certain columns inbetween to be omitted?

  11. #11
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Excel 365: How to put a MAX function into an array?

    Sorry, I misread.

    I don't think there's an easy solution.
    Better restructure your data to make them contiguous.
    After all, spilling is also happening into contiguous cells, so pulling data from non-contiguous cells is counterintuitive to being with.

    Based on the file I attached, you can have empty columns inbetween the two columns from which you wish to pull the max, but if there's other data inbetween, you're most likely out of luck.

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,750

    Re: Excel 365: How to put a MAX function into an array?

    Someone named Lori is famous for coming up with formulas that solve outrageously difficult problems.

    This is one of them. Though we aren't supposed to post links to competing forums this one is too complicated to explain here and the workbook I used this in is a 'train wreck'. I just know this formula works at my end. Array references in this formula are to a simulation of a calculated array.

    The link: By Lori (Post #35 first of 2)

    The formula I used array entered Control + Shift + Enter
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    You will need to see hers in the context of that link.

    The simulated array mentioned above:
    {40,29,27,2;21,39,12,37;50,35,31,26;0,50,37,10;35,9,20,29;49,16,44,-49;48,20,15,2;18,12,0,19;28,40,46,16;5,25,11,38}

    I played with this for days about 4 or 5 years ago. I never experimented with blanks. Perhaps this will give you a start.

    Hope this is of some use.

    Edit: PS Come to think of it I believe she also included a formula somewhat similar to the one posted by XOR LX above in that link, but I didn't go looking for it.
    Last edited by FlameRetired; 10-18-2021 at 05:15 PM.
    Dave

  13. #13
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2409
    Posts
    207

    Re: Excel 365: How to put a MAX function into an array?

    Vielen Dank, RaulSerg. I can't place the columns continguously, as it messes up the logic of the data to the end-user. I have, however, placed a helper column contiguously and hidden it, so that works fine.
    By the way, where in Germany are you? Until recently, I was living in Kassel.

    And FlameRetired, I haven't tried the formula, though I'm sure I could get it to work. For the given situation, it's simply too complex for my needs. I appreciate the suggestion, maybe someone else can make use of it. Thanks.

  14. #14
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2409
    Posts
    207

    Re: Excel 365: How to put a MAX function into an array?

    That's a very useful alternative, FlameRetire. I'm running with the other solution suggested by RaulSerg, because I can follow it easier.

  15. #15
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,791

    Re: Excel 365: How to put a MAX function into an array?

    If your two spill ranges are in P2 & S2 you could use
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    EDIT:
    This assumes that both spill ranges are 1 column wide & the same number of rows.
    Last edited by Fluff13; 10-24-2021 at 02:37 PM.

  16. #16
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2409
    Posts
    207

    Re: Excel 365: How to put a MAX function into an array?

    Ah yes, @Fluff13, so simple, I should have thought of that. For this situation, that's all I need. Thanks...

  17. #17
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,791

    Re: Excel 365: How to put a MAX function into an array?

    Glad to help & thanks for the feedback.

+ 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] vba excel calling an array within a Find function
    By terriertrip in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-29-2020, 01:21 PM
  2. [SOLVED] Help with excel array into Forecast function
    By alexpignatelli in forum Excel General
    Replies: 12
    Last Post: 02-15-2018, 05:35 PM
  3. Array Function: Using an array function to calculate loan outstanding
    By akshaythakker in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 08-30-2016, 05:33 PM
  4. [SOLVED] Excel pro rata if or array function
    By bunts011 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-29-2014, 09:15 PM
  5. Using the ReDim array function in a multidimensional array in excel
    By Doruli in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-05-2012, 01:43 PM
  6. Passing array from Access to Excel function
    By Dale in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-29-2005, 03:05 PM
  7. [SOLVED] Excel Function in what appears to be an array
    By Rusty in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-03-2005, 12:06 PM

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