+ Reply to Thread
Results 1 to 4 of 4

I have 2 ranges and I would like to apply the MAX function to them and have a range again

  1. #1
    Registered User
    Join Date
    02-09-2023
    Location
    London
    MS-Off Ver
    365
    Posts
    6

    I have 2 ranges and I would like to apply the MAX function to them and have a range again

    This is my problem: I have two ranges and I would like to get the MAX value for each row and have a again a range to SUM.
    A B C
    1 Available Needed Missing=MAX(0,Needed-Available)
    2 10 5 0
    3 10 15 5
    4 5 10 5
    5 15 10 0
    6 total SUM(C2:C5) 10

    I would like to calculate the total of Missing without the Missing column, I thought I could do something like this: SUM(MAX(0,B2:B5-C2:C5)) but it doesn't work.
    Actually I solved it with a IF function mimicking the MAX function: SUM(IF(B2:B5-C2:C5<0,0,B2:B5-C2:C5)) but I was wondering if it was possible to use the MAX function or if there is another function to calculate the MAX of a range and return a range again.

    Edit:
    I have found another way to do it with the MAX function, although I find it even less "readable" than the version with the IF function.
    This solution uses the BYROW function: SUM(BYROW(B2:B5-C2:C5,LAMBDA(row,MAX(0,row))))

    I was hoping to find something simple and "readable" ...
    Last edited by Whoops; 02-09-2023 at 12:01 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-23-2021
    Location
    Romania
    MS-Off Ver
    2021, 365 v 2208
    Posts
    722

    Re: I have 2 ranges and I would like to apply the MAX function to them and have a range ag

    Hi,
    Something like this?
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Diana Tanase


    If the solutions offered helped you to solve your problem, then mark the thread as SOLVED (thread tools in the top menu) and you can click on * to add reputation to those who helped you, as a way to say thank you !

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: I have 2 ranges and I would like to apply the MAX function to them and have a range ag

    Quote Originally Posted by tanasedn View Post
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Note: This solution works in 2021 and 365 as shown. However, to use this in 2016 you will have to enter it as an array formula. After typing in the formula, do not hit ENTER--hit CTRL+SHIFT+ENTER. You have done it correctly if the formula in the formula box has {braces} around it. You cannot type in the braces; they are just an indicator that it is an array formula.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    02-09-2023
    Location
    London
    MS-Off Ver
    365
    Posts
    6

    Re: I have 2 ranges and I would like to apply the MAX function to them and have a range ag

    Quote Originally Posted by tanasedn View Post
    Hi,
    Something like this?
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thanks for the reply, I found this solution too (s. original post).
    I can live also with that but I find that a formula with the MAX function is more readable than this one.

+ 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. VSTACK function with named ranges in a range
    By Lollpopp in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-02-2023, 02:06 PM
  2. [SOLVED] Apply Right Function to range of cells
    By chrisellis250 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-10-2019, 09:00 AM
  3. Apply function to Ranges
    By bjcowen9000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-18-2013, 01:17 AM
  4. Replies: 1
    Last Post: 02-02-2013, 06:58 PM
  5. [SOLVED] Apply macro to multiple ranges
    By sans in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-28-2012, 11:07 AM
  6. Macro or function that changes value of selected range or ranges of cells
    By ychartra01 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-06-2009, 06:11 PM
  7. [SOLVED] How can I apply the ROUND function to a range of cells in a workbo
    By Ellemarr in forum Excel General
    Replies: 5
    Last Post: 06-10-2005, 09:05 PM

Tags for this Thread

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