+ Reply to Thread
Results 1 to 16 of 16

Multiple true statements but need one to override the other

  1. #1
    Registered User
    Join Date
    06-27-2014
    Location
    Poole England
    MS-Off Ver
    2013
    Posts
    10

    Question Multiple true statements but need one to override the other

    example workbook for forum.xlsxHi all, I have only been writing formulas for excel for a day and i'm struggling with an issue that i hope someone can help me with here. I have a formula iv'e put together which searches for key words in two cells and returns values based on the true results. The problem i have run into is when more than two keywords are true in either cell i get both results in the target cell rather than one, and i need only one. e.g if B2 or G2 contain the word "edging" then the value '40' is returned, if "oak" is in either of these cells then '2*E2' is returned, rounded up to the nearest 100 (for this eg 100), if both of these words exist in either cells then the result is '10040', but i need the formula to preference "edging" over "oak" and return only '40'.

    here is the formula as it stands, it is a work in progress, it is supposed to add extra waste material for a cutting sheet.

    =CONCATENATE(IF(SUMPRODUCT(--(ISNUMBER(SEARCH({"s/wood","softwood"},G4&B4))))>0,((ROUNDUP(2*E4,-2))),""),IF(SUMPRODUCT(--(ISNUMBER(SEARCH({"poplar","oak","sapele","walnut","ash","beech","birch","cherry","maple","iroko","cedar","balsa","olive"},G4&B4))))>0,((ROUNDUP(2*E4,-2))),""),IF(ISNUMBER(SEARCH("solid surface",G4)),(10),("")),IF(ISNUMBER(SEARCH("corian",G4)),(10),("")),IF(SUMPRODUCT(--(ISNUMBER(SEARCH({"edging","lipping"},B4&G4))))>0,"40",""),IF(SUMPRODUCT(--(ISNUMBER(SEARCH({"balance","veneer","laminate"},B4&G4))))>0,"20",""),IF(SUMPRODUCT(--(ISNUMBER(SEARCH({">"},G4))))>0,((ROUNDUP(2*E4,-2))),""),IF(SUMPRODUCT(--(ISNUMBER(SEARCH({"<"},G4))))>0,"100",""))
    Last edited by matt318; 06-27-2014 at 05:25 AM.

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

    Re: Multiple true statements but need one to override the other

    Hi and welcome to the forum!

    Obviously to dissect that formula out of context (i.e. without seeing the actual workbook) will be a thankless and near-impossible task.

    Kindly upload one, replacing confidential information with dummy data if necessary.

    Regards
    Click * below if this answer helped

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

  3. #3
    Registered User
    Join Date
    06-27-2014
    Location
    Poole England
    MS-Off Ver
    2013
    Posts
    10

    Re: Multiple true statements but need one to override the other

    I have attached an example workbook to the first post.

    Column K, L & M are additional waste material columns, S, T & U are calculated values for the cutting sheet, columns B & G are where the description and material type are written and the rest should be pretty self explan. I've put in some example text to show you what is happening at the moment. in G6 i have put a specialist material which isnt in the search criteria of the formula to illustrate what the manual override symbol '>' does. row7 throws up the issue i mentioned in my original post, as does 8, they need to choose just the edging or lipping keywords as 100 is too much waste for edgings and lippings.


  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: Multiple true statements but need one to override the other

    Thanks.

    And would you be amenable to receiving a completely new solution, if that turned out to be possible, or would you prefer to keep your existing solution and have it amended so that it works?

    I only say that as sometimes it's easier to tackle a problem from first steps than to try to dissect someone else's (in this case rather long) formula.

    If you are open to that possibilty, could you confirm which of the values in your sheet are correct, and, if not, what they should be (you say that rows 7 and 8 are an issue, though I've no idea what the answer should be).

    Regards

  5. #5
    Registered User
    Join Date
    06-27-2014
    Location
    Poole England
    MS-Off Ver
    2013
    Posts
    10

    Re: Multiple true statements but need one to override the other

    I'm definitely open to new solutions, i do need to add new material keywords in the future so as long as i am able to do that i'm happy. I will try to make it as easy to understand as possible what should be going on with the following info.



    here is a list of the materials and descriptions and their corresponding waste amounts (in mm)

    "softwood" or "s/wood" in either column B or G = 2x the material width (Column E) rounded up to the nearest 100, for additional length only.
    "veneer" or "laminate" in either column B or G = 20 for length and width
    "edging" or "lipping" in either column B or G = 40 for length and 4 for width
    "ash", "oak", "sapele", "softwood" or other wood types in column G = 2x the material width (Column E) rounded up to the nearest 100, for additional length only.
    "solid surface", "corian" = 10 additional for length and width




    "edging" or Lipping" may appear in description column B (as part of the description e.g panel 1 edging) at the same time that "oak" or "ash" (or "oak edging" or "ash edging") may appear as the material description but the item is an edging/lipping and as such only needs 40mm additional waste material added to the length and 4mm to the width. It should not be treated as a solid piece of timber which needs 2 x item width rounded to the nearest 100mm. A solid piece of timber would only be identified to the workbook as a wood type name in the material column and would not have "edging" or "lipping" in the description, instead its description would subjective to the individual booking off the item but the material would definitely be a timber type.

    The edging and lipping rule applies similarly for "veneer" & "laminate".

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

    Re: Multiple true statements but need one to override the other

    Thanks, so based on that, could you let me know which of your current entries in column K is correct? And, if not, what it should be?

    Regards

  7. #7
    Registered User
    Join Date
    06-27-2014
    Location
    Poole England
    MS-Off Ver
    2013
    Posts
    10

    Re: Multiple true statements but need one to override the other

    I forgot to say that the issues in row 7 & 8 are that the additional lengths should be "40" not "10040", obviously the formula is returning 40 and 2x44 (rounded up to 100).

  8. #8
    Registered User
    Join Date
    06-27-2014
    Location
    Poole England
    MS-Off Ver
    2013
    Posts
    10

    Re: Multiple true statements but need one to override the other

    The rest are correct

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

    Re: Multiple true statements but need one to override the other

    Quote Originally Posted by matt318 View Post
    "softwood" or "s/wood" in either column B or G = 2x the material width (Column E) rounded up to the nearest 100, for additional length only.

    "ash", "oak", "sapele", "softwood" or other wood types in column G = 2x the material width (Column E) rounded up to the nearest 100, for additional length only.
    Great. Thanks. And can you just clarify why there are separate clauses in your current formula for each of these searches, when they appear to have an identical output?

    Regards

  10. #10
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Multiple true statements but need one to override the other

    matt, it seems like you are familiar with setting up a basic IF function such as =IF(A2="oak",40,"")
    You have been using CONCATENATE here to combine IF functions such as =CONCATENATE(IF(A2="oak",40,""),IF(B2="edging",100,""))
    However, a more common way of doing it is to nest the IF functions like this: =(IF(A2="oak",40,IF(B2="edging",100,"")))
    When using nested IF functions you can set the priority by the order in which they appear. In the above example the A2="oak" condition has priority. In other words, if A2="oak" turns out to be true then you will get 40 and Excel won't bother to look at the next IF (B2="edging").


    In my attached sheet I have been using Alt + Enter to get line breaks in the formula and some extra spaces to line things up, makes it easier to read. If grab the lower lip of the formula bar and pull down you will be able to see the whole thing.

    I have also deleted a few unnecessary parathesis. I have also deleted a few >0 as they are not really necessary. Excel considers any number that is not 0 to be TRUE in an IF function. I consolidated some searches for material as the search was done in the same cells producing the same result. However, if you want some sort of priority between them then you may want to split them up again.
    Attached Files Attached Files
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  11. #11
    Registered User
    Join Date
    06-27-2014
    Location
    Poole England
    MS-Off Ver
    2013
    Posts
    10

    Re: Multiple true statements but need one to override the other

    Yes... sorry that would be an error on my part, the formula started of being only for softwood to be auto calculated for additional waste and all other wood types wastes to be added manually, this should have been altered for all wood types including the generic "softwood" or "s/wood" material we give to carcass grade softwood.

  12. #12
    Registered User
    Join Date
    06-27-2014
    Location
    Poole England
    MS-Off Ver
    2013
    Posts
    10

    Re: Multiple true statements but need one to override the other

    Thanks Jacc, ill DL that now and have a look at your handywork

  13. #13
    Registered User
    Join Date
    06-27-2014
    Location
    Poole England
    MS-Off Ver
    2013
    Posts
    10

    Re: Multiple true statements but need one to override the other

    Hi Jacc, thanks for your help, much appreciated. Do i have a limit to the amount of if functions i can nest?

  14. #14
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Multiple true statements but need one to override the other

    I think that there used to be a limit of 7 nested if's in Excel 2003 and older but from Excel 2007 and newer it's 64. However, if your heading down the road of lot's of nested if's you should reconsider your whole setup. The setup you have is not a concern if you ask me.

    I fixed the other formula too. On another tab I converted it to an Excel Table. This feature can use headers instead of cell addresses in formulas (which I opted not too use). The reason I did convert it is that it expands all your formula and formatting automatically if new data is added anywhere in the row below the last row, no need to copy down to row 500 "just in case".
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    06-27-2014
    Location
    Poole England
    MS-Off Ver
    2013
    Posts
    10

    Re: Multiple true statements but need one to override the other

    You're the man! Little bit of re ordering of the nests and its pretty much done..... i'm adding you as a friend

  16. #16
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Multiple true statements but need one to override the other

    Glad to hear it works! :)
    I made an attempt of making it more dynamic here, new types of wood can easily be added but if you want a new resulting value it will still require some work from you (creating a new table).

    Making a proper Lookup setup with the possibility to easily change the resulting value for different kinds of wood will require running array formulas and the formula will be a lot bigger, as far as I can see. A UDF would be an option ofcourse.

    I added a space between the cells to be searched to prevent the risk of "creating" words that don't exist. Hmm... now that I think about it that could go either way...:)

    I have to say that apart from the CONCATENATE setup I am pretty impressed with the original SUMPRODUCT/SEARCH concept, it's hard to improve. :)
    Attached Files Attached Files

+ 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] If statement UDF with the possibility of multiple true statements (how to fix)?
    By Excel2010101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-12-2014, 01:45 AM
  2. Override Cell Contents with True and False Reports
    By ryanb4614 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-01-2013, 11:15 AM
  3. Using Multiple "IF" Statements to get Three Different True Values
    By rehankins in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-15-2013, 12:49 AM
  4. Multiple true statements with a return value
    By Cameleon80 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-27-2012, 09:16 AM
  5. If 3 conditions are true statements
    By Teresa in forum Excel General
    Replies: 5
    Last Post: 10-05-2011, 04:17 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