+ Reply to Thread
Results 1 to 29 of 29

If cell has numbers and specific text, sum numbers with multiple criteria

  1. #1
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    If cell has numbers and specific text, sum numbers with multiple criteria

    Hi,

    My table has multiple cells with text and values in the same cell, I want to be able to sum the numbers that are in the same cell as the text "SP", but only when those cells are in the same row as the "Attack" row and also broken down into different the different stances on the overview page.

    I have been trying the SUMPRODUCT formulas and believe I am close with this:
    =SUMPRODUCT((INDIRECT($E$5&"[Style]")=G8)*(INDIRECT($E$5&"[Attack/Defense]")="Attack")*(INDIRECT($E$5&"[[1]:[13]]")<>"")*(INDIRECT($E$5&"[[1]:[13]]")<>"MISS")*(LEFT(INDIRECT($E$5&"[[1]:[13]]"),2)="SP"),(IF((LEFT(INDIRECT($E$5&"[[1]:[13]]"),2)="SP"),(SUBSTITUTE(INDIRECT($E$5&"[[1]:[13]]"),"SP","")+0),0)))

    But I keep getting #value error.

    If I analyse the two arrays in this formula with F9, it gives the correct values and both seem to be the same size but it wont do the final calculation?

    Any help would be much appreciated!

    Sample worksheet below: Refer to formulas in the "special hits" columns of the overview page.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    Cell I3 in the lookup sheet contains text AFTER the number as well. Will the number always be 3 digits?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    No It can vary from 1 to 3, but most commonly with the special hits it will be 3

  4. #4
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    The text after the numbers in I3 is an uncommon variable. It is a way of showing that during a "Special" the opponent had a "Shield => "special" "hit point value" "opponent shield" as per the reference

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    I think you are making this far too complicated. If it were me, I would not have both text and numbers in the same cell.

  6. #6
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    Unfortunately Im pulling the data from a website and ive already spent a significant amount of time to get it to this format. this format is giving me the most info in the simplest configuration (obviously not for this situation).

  7. #7
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    I should be able to reconfigure it so that all the text is on the LHS if that helps at all?

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    No. And that's why I'm stepping aside on this one - sorry. Hopefully someone else will be able to help you.

    EDIT: Just seen your latest post - it might help.

  9. #9
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    Ive updated the workbook, Ive just moved all of the text to the LHS for the time being, In I3 I have seperated the two text with a comma. Not sure a bout the configuration but it might help?
    Attached Files Attached Files

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    No - IP3 shows just SP 137 now!

    This is as close as I can get you I'm afraid:

    =SUMPRODUCT((INDIRECT($E$5&"[Style]")=G6)*(INDIRECT($E$5&"[Attack/Defense]")="Attack")*((LEFT(INDIRECT($E$5&"[[1]:[13]]"),2)="SP")),IFERROR(VALUE(MID(INDIRECT($E$5&"[[1]:[13]]"),4,3)),0))

  11. #11
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    Thanks for trying,

    That still returns #value error.

    Im still confused as to why my original formula shows the correct values when using F9 on both the arrays, and in theory it should spit out the answer but it doesnt?

  12. #12
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    E.g:
    =SUMPRODUCT({0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,1,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,1,0,1,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,137,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,125,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,182,0,200,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0})

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    That still returns #value error.
    No, it doesn't! See attached.

    in theory it should spit out the answer but it doesnt?
    In practice, the null values ("") in the arrays cause #VALUE! errors.

    I'm done with this one - sorry.
    Attached Files Attached Files

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    I've put out a call for help to the community. Good luck with this.

  15. #15
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    thankyou for trying!
    Last edited by jj2105; 05-30-2022 at 10:52 PM.

  16. #16
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    Sorry Im a bit confused, This formula you added to the workbook doesnt work if you click on the formula to look at it, it removes the brackets from the beginning and end and goes back to #value error?
    Last edited by AliGW; 05-30-2022 at 11:52 PM. Reason: PLEASE don't quote unnecessarily

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

  18. #18
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,577

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    Try this ARRAY formula in L6, copy down
    Please Login or Register  to view this content.
    To enter ARRAY formula
    Copy and paste the formula in cell
    Press F2
    Press Ctrl+Shift+Enter together
    Excel covers the formula with {}.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  19. #19
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    Okay, so I still don't fully understand how the array formula is different to the standard formula in my particular case, but if I put the original formula that I wrote into an array formula it works . Will this impact/give me issues if I run with the original formula from the first worksheet I uploaded? I know its overly complicated, but if it doesn't impact it I think that the first formula might give me a bit more variation to create more criteria, i.e another column that calculates the hits with opponent shield (OSH) rather than calculating the specials.
    Last edited by jj2105; 05-31-2022 at 03:34 AM.

  20. #20
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    Which of us are you addressing?

    You need to test this on other versions of your workbook as you are the one who has the data. That's not our job, so try it, test it and come back to us with any issues that arise.

  21. #21
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).[/QUOTE]

    *Edit: I just read your last post, so that array formula is the same as my original and just adds the "if theres an error, = 0 " is that correct?

    Edit Again: Apologies I didn't realise it was a different person.
    Last edited by AliGW; 05-31-2022 at 04:00 AM. Reason: Please do NOT post-edit posts in this way!!!

  22. #22
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    Quote Originally Posted by AliGW View Post

    hat's not our job, so try it, test it and come back to us with any issues that arise.
    What I'm trying to ask is, what's the difference? I have 2 formulas exactly the same, ones an array, one isn't, the array appears to give me the correct answer, the other gives me error. All my other formulas have not been array formulas (part of which you thankfully helped with) and are assessing similar criteria and they work.
    You originally gave me an array formula to try and said "this is as close as I can get, I'm done with this, I've put a call out to the community for help". So I am assuming you think there is some sort of issue with the formula, otherwise you would have just said use this, hence the question.

    Also I do not expect you to analyse my whole workbook, I know that's not "your job".

  23. #23
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    Quote Originally Posted by kvsrinivasamurthy View Post
    Try this ARRAY formula in L6, copy down
    .
    Thankyou!!! Ive tested this and it looks like it works perfectly, Im also able to change some of the critieria to fit different questions.

    Just so I can try and understand it a bit better what is the reason for wrapping it in the ifferror?
    Last edited by jj2105; 05-31-2022 at 03:57 AM.

  24. #24
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    So I am assuming you think there is some sort of issue with the formula, otherwise you would have just said use this, hence the question.
    No, it simply means what I said: it's the closest I can get you to a solution. I have my limits! I am no Excel expert (I'm a retired languages teacher): I offer my expertise here where I can and am able, for the most part, to help those I engage with to a conclusion. On this occasion I'm not able to get any further. This does not mean I think there is something WRONG with the formula, simply that it might not do EVERYTHING you want it to do. This is why I put out a call for help to the wider community.

    Again - you need to stress test these things and then come back to us with issues, if they arise.

  25. #25
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    No problem, that would have got me pretty close, I just didn't (and still dont really) understand the whole array formula thing and why it was giving a different result.

    Thanks for putting the call out and thanks kvsrinivasamurthy for answering. I now have a formula I can adapt!

    I am always very hesitant to ask questions on these places so I try and do everything myself as much as possible.
    I by no means expect you to do everything for me, this is a part of a much larger worksheet which I'm trying to get through with very little knowledge and trying to ask the right questions along the way.

    Thankyou for your help!

  26. #26
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    To try to answer the question I think you are asking: in your version of Excel, an array formula will not be recognised automatically, so you have to tell Excel how to process it by entering it with CTRL+SHIFT+ENTER. If you don't only the top row of each array will be processed, not the whole array, and this will lead either to error messages or the wrong result (or, just occasionally, the right result by chance).

    In newer versions you don't have to prompt Excel: it makes a decent job of working out what needs to be treated as an array formula or not.

    To see the difference, enter an array formula WITHOUT CTRL+SHIFT+ENTER and then run it through Evaluate Formula (limit the size of the arrays in the test data to see what's happening more easily). Now run the same formula through having entered it correctly. You should see and hopefully understand a significant difference in behaviour.

  27. #27
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,577

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    Asking questions and getting help are not bad . They definitely improve the knowledge.
    Thanks for feedback and rep.

  28. #28
    Registered User
    Join Date
    05-25-2022
    Location
    adelaide
    MS-Off Ver
    2016
    Posts
    34

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    @AliGW

    Okay thanks, this makes more sense. I didn't even know the evaluate function existed so I'm learning!
    I must of just got lucky with some of my other formulas with arrays that worked

    So essentially anytime I'm entering a formula with an array (i.e not just the 1 row), because of my early version of excel, I need to use CTRL+SHIFT+ENTER for it to analyse that array correctly?
    Last edited by AliGW; 05-31-2022 at 05:37 AM. Reason: PLEASE don't quote unnecessarily!

  29. #29
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: If cell has numbers and specific text, sum numbers with multiple criteria

    Yes, that's correct. If you enter a formula that does NOT need to be entered as an array as one, it won't hurt, so if in doubt, array enter. Of course you need to array enter and THEN drag copy the formula across or down.

    Basic SUMIF(S), COUNTIF(S), etc. do not need array entering.

    The evaluate formula function is really helpful as long as you limit your test arrays - because you can't enlarge the dialog box, it's better this way.

    I'm glad you've learnt something: the teacher in me wants that to happen!
    Last edited by AliGW; 05-31-2022 at 05:45 AM.

+ 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. Find specific Numbers in a cell with a lot of text
    By luca.pe in forum Excel Formulas & Functions
    Replies: 22
    Last Post: 05-13-2022, 04:52 AM
  2. Multiple criteria for Conditional Formatiing with numbers and text
    By Bdubsard in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-20-2022, 10:23 AM
  3. [SOLVED] Extract the text and numbers basis on specific numbers included
    By Neilesh Kumar in forum Excel General
    Replies: 6
    Last Post: 08-26-2018, 01:34 PM
  4. [SOLVED] Summation of Numbers with Text & Numbers in Multiple Cells with Multiple Criteria...
    By e4excel in forum Excel Formulas & Functions
    Replies: 25
    Last Post: 09-14-2017, 01:46 PM
  5. [SOLVED] Average of specific cells with numbers determined by multiple criteria
    By holycrapitsaduck in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 07-27-2016, 10:40 AM
  6. [SOLVED] Add numbers based on criteria from specific cell on same row
    By nitreb in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-21-2013, 05:13 PM
  7. [SOLVED] How to change numbers to negative numbers specific with a text
    By Patnaik in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-11-2012, 07:22 AM

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