+ Reply to Thread
Results 1 to 12 of 12

MAX IF array inside an IF formula??

Hybrid View

  1. #1
    Registered User
    Join Date
    04-28-2016
    Location
    Manchester, England
    MS-Off Ver
    Office 365
    Posts
    13

    Smile MAX IF array inside an IF formula??

    Good morning/ afternoon all,
    I am new to this forum so would like to start by saying hello to everyone.

    I have searched numerous forums and google but cannot seem to find any help on this particular topic and I am hoping someone here can offer some input/assistance.

    I would like to run a max if formula which I can do as an array which is fine. however I would like to put this array inside another if formula.

    so if cell A1 is blank, then max if array based on other cell entries, but if cell a1 is not blank or greater than 0, then I want a max if(s) array to run to include the value in this cell.

    I understand how to do the max if array and an array for max if(s) but cannot figure out how to enter 2 array forumlas into a single cell based on a standard IF formula.

    Any help would be much appreciated.

    attached file:

    so it is cells H5:H16 I am trying to fill out. It depends on whether we are entering the value into cell H2. If cell H2 is empty, then we will only find max days open per user (listed in column A). The number of days open is on the data import sheet column AB. The usernames in the dataimport sheet are in column K and the customer number column E.
    Attached Files Attached Files
    Last edited by mtleigh; 04-28-2016 at 08:57 AM. Reason: file attached

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: MAX IF array inside an IF formula??

    1. It would help to see the workbook.

    You get better help on your question if you add a small excel file, without confidential information.

    Please also add manualy the expected result in your file.

    To Attach a File:

    1. Scroll down to the window below your post Additional Options
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    04-28-2016
    Location
    Manchester, England
    MS-Off Ver
    Office 365
    Posts
    13

    Re: MAX IF array inside an IF formula??

    I think I have managed to add some more comments to my original post along with an attachment.

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: MAX IF array inside an IF formula??

    Hello and welcome new person

    Just enter it all as one single array formula, something like

    {=IF(A1<0,MAX(IF(...)),MAX(IF(...)))}

  5. #5
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: MAX IF array inside an IF formula??

    You were close, 1 bracket in the wrong place, and you didn't array confirm your formulas in H5:H16.

    H5 should be

    =IF($H$2>0,MAX(IF('Data Import'!K:K=Summary!A5,IF('Data Import'!E:E=Summary!$H$2,'Data Import'!AB:AB))),MAX(IF('Data Import'!K:K=Summary!A5,'Data Import'!AB:AB)))

    Remember to confirm the array formula with Shift Ctrl Enter before filling down.

  6. #6
    Registered User
    Join Date
    04-28-2016
    Location
    Manchester, England
    MS-Off Ver
    Office 365
    Posts
    13

    Re: MAX IF array inside an IF formula??

    Haha no way just 1 bracket. - I can't believe I forgot to CSE. Thank you works perfectly now

  7. #7
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: MAX IF array inside an IF formula??

    with a pivot table.

    I deleted the rows after row 500 since the file was to big to post.

  8. #8
    Registered User
    Join Date
    04-28-2016
    Location
    Manchester, England
    MS-Off Ver
    Office 365
    Posts
    13

    Re: MAX IF array inside an IF formula??

    so I realised that the above formula did not do exactly what I needed as I missed some date cells out so I need to ensure the calculation is based only between 2 dates which I have now included. this is the VBA code but it is not working and I get the debug error every time. I am sure I must be a bracket missing or int he wrong place. can anyone take a quick look and provide any solutions?

    Selection.FormulaArray = _
    "=IF(R2C8>0,MAX(IF('Data Import'!C[3]=Summary!RC[-7],IF('Data Import'!C[2]>=Summary!R2C4,IF('Data Import'!C[2]<=Summary!R2C5,IF('Data Import'!C[-3]=Summary!R2C8,'Data Import'!C[20]))))),MAX(IF('Data Import'!C[3]=Summary!RC[-7],IF('Data Import'!C[2]" >= "Summary!R2C4,IF('Data Import'!C[2]" <= "Summary!R2C5,'Data Import'!C[20]))))"

  9. #9
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: MAX IF array inside an IF formula??

    Not sure about brackets, but you have some stray double inverted commas which will be causing problems.
    Also, I don't think that FormulaArray will accept R1C1 cell references, you might have to enter it as a regular R1C1 formula, then force that to an array afterwards.

    Untested

    Selection.FormulaR1C1 = _
     "=IF(R2C8>0,MAX(IF('Data Import'!C[3]=Summary!RC[-7],IF('Data Import'!C[2]>=Summary!R2C4,IF('Data Import'!C[2]<=Summary!R2C5,IF('Data Import'!C[-3]=Summary!R2C8,'Data Import'!C[20]))))),MAX(IF('Data Import'!C[3]=Summary!RC[-7],IF('Data Import'!C[2] >= Summary!R2C4,IF('Data Import'!C[2] <= Summary!R2C5,'Data Import'!C[20]))))"
    Selection.FormulaArray = Selection.Formula

  10. #10
    Registered User
    Join Date
    04-28-2016
    Location
    Manchester, England
    MS-Off Ver
    Office 365
    Posts
    13
    Quote Originally Posted by jason.b75 View Post
    Not sure about brackets, but you have some stray double inverted commas which will be causing problems.
    Also, I don't think that FormulaArray will accept R1C1 cell references, you might have to enter it as a regular R1C1 formula, then force that to an array afterwards.

    Untested

    Selection.FormulaR1C1 = _
     "=IF(R2C8>0,MAX(IF('Data Import'!C[3]=Summary!RC[-7],IF('Data Import'!C[2]>=Summary!R2C4,IF('Data Import'!C[2]<=Summary!R2C5,IF('Data Import'!C[-3]=Summary!R2C8,'Data Import'!C[20]))))),MAX(IF('Data Import'!C[3]=Summary!RC[-7],IF('Data Import'!C[2] >= Summary!R2C4,IF('Data Import'!C[2] <= Summary!R2C5,'Data Import'!C[20]))))"
    Selection.FormulaArray = Selection.Formula
    I have removed the apostrophes as stated as realised after posting. Still not working. I now get a message wgich i beleive relates to the lengrh od my formula. I dont think i can have a Formula more than 255 digits for an array in vba so now i am havig to rethink.

  11. #11
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: MAX IF array inside an IF formula??

    Quote Originally Posted by mtleigh View Post
    I dont think i can have a Formula more than 255 digits for an array in vba so now i am havig to rethink.
    Same formula, with a different approach to the logic. Consider reducing the range sizes as well, using entire columns in array formulas is extremely inefficient.

    Selection.FormulaArray = _
     "=MAX(IF('Data Import'!C[3]=Summary!RC[-7],IF('Data Import'!C[2]>=Summary!R2C4,IF('Data Import'!C[2]<=Summary!R2C5,IF(R2C8>0,IF('Data Import'!C[-3]=Summary!R2C8,'Data Import'!C[20]),'Data Import'!C[20])))))"
    One point to note, I was wrong with my earlier comment, you can use R1C1 references with FormulaArray, just tested the above in excel and it works as expected.

  12. #12
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: MAX IF array inside an IF formula??

    you don't reply on my solution in #6.

+ 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. use of array formula inside function
    By maxtrick in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-10-2016, 03:42 PM
  2. Replies: 1
    Last Post: 07-31-2014, 10:16 AM
  3. [SOLVED] Search between dates inside a MATCH array formula
    By BlueAstro in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-04-2014, 01:02 PM
  4. [SOLVED] VLOOKUP inside array formula
    By dipique in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-02-2013, 06:24 PM
  5. Dynamic range inside array formula with use of match
    By konradz in forum Excel General
    Replies: 2
    Last Post: 06-23-2012, 10:54 AM
  6. * Inside a SUM array
    By KHaberstroh in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-29-2009, 12:17 PM
  7. Modifying Data inside an array
    By icdoo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-16-2006, 02:35 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