+ Reply to Thread
Results 1 to 7 of 7

Need help with finding text in a cell.

Hybrid View

  1. #1
    Registered User
    Join Date
    08-29-2013
    Location
    Kaunas, Lithuania
    MS-Off Ver
    Excel 2010
    Posts
    3

    Need help with finding text in a cell.

    Hello,

    I read countless topics about similar issues but I still can't get it to work.

    If I have a value 150x150x6x12000 S355 in B39. I want to return the value 562 in another cell, if B39 ends with 255. If not, then it's 610, UNLESS the cell contains x6x (as opposed to let's say x5x). If it ends in 355 AND contains x6x then it should return 615.

    How could I do that?

    I am convinced this should work: =IF(ISNUMBER(SEARCH(235; B67)); 562; (IF(ISNUMBER(SEARCH(X6X;B67)); 615; 610)))

    But it never returns 615. Only 255 or 610.

    Any thoughts on what I'm doing wrong? Am I using the nested IF wrong?

    Thanks

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Need help with finding text in a cell.

    =IF(ISERROR(FIND("x6x",B5)),IF(RIGHT(B5,3)="255",562,610),IF(RIGHT(B5,3)="355",615,0))
    Last edited by rcm; 08-29-2013 at 10:42 AM.

  3. #3
    Valued Forum Contributor TheCman81's Avatar
    Join Date
    11-06-2012
    Location
    Edinburgh, UK
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    346

    Re: Need help with finding text in a cell.

    Hi

    Will something like this work for you

    Attachment 261659
    Excel Guru in the making

    <----------If the question has been answered to your satisfication please click the Add Repuation star to the left

  4. #4
    Registered User
    Join Date
    08-29-2013
    Location
    Kaunas, Lithuania
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Need help with finding text in a cell.

    For some reason both of those solutions don't work on my excel sheet :/ It returns 610 in any case. Any ideas what could be the reason?

  5. #5
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Need help with finding text in a cell.

    Quote Originally Posted by n3xas View Post
    Though I'm still a bit confused about ISNUMBER, can you use it in any similar situation or not. The description says it only checks if the value is a number, so how does it work here
    using your eg of this in B39:
    =IF(ISNUMBER(SEARCH(235, B39)), 562, (IF(ISNUMBER(SEARCH("X6X",B39)),615, 610)))
    the SEARCH formula returns the starting position of whatever you are looking for. so when you are looking for 235, the SEARCH formula alone gives you a #VALUE error. you can try this separately on another cell:
    =SEARCH(235, B39)
    that's because 235 cannot be found in B39. the ISNUMBER here is to determine if whatever you are searching for can be found. otherwise, your formula would just stop & give you a #VALUE error. so in this case, the ISNUMBER will say that #VALUE is not a number & gives you FALSE. when it's FALSE, it will proceed to the next IF. and that is to search for "X6X" in B39. this time, it finds it & return you position number 8. again, you would need the ISNUMBER to return TRUE or FALSE. because it is now a number, it will return you the value you desire; 615.

    if that answers your questions, do mark this thread as "Solved"

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  6. #6
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Need help with finding text in a cell.

    welcome to the forum n3xas. a better explanation would be to show the desired results for the different scenarios
    150x150x6x12000 S355
    contains both "x6x" & ends with 355. what should it show? 615?

    150x150x5x12000 S355
    does not contain "x6x" & ends with 355. what should it show? 610?

    150x150x5x12000 S255
    does not contain "x6x" & ends with 255. what should it show? 562

    if i'm correct, then:
    =IF(COUNTIF(B39,"*x6x*"),615,IF(RIGHT(B39,3)="355",610,562))
    otherwise, let us know the answers to the above scenario and other scenarios you have.

    an explanation of the formula you have:
    =IF(ISNUMBER(SEARCH(235; B67)); 562; (IF(ISNUMBER(SEARCH(X6X;B67)); 615; 610)))
    if 235 is found anywhere in B67, put it as 562.
    the second search isn't valid because you need to put double quotes when searching for texts like "x6x". so if i put the double quotes, it will return 615 if "x6x" is found in B67
    only when the 2 tests fails, it will return 610. so changing it to this will work (if i assume correctly):
    =IF(ISNUMBER(SEARCH(235, B39)), 562, (IF(ISNUMBER(SEARCH("X6X",B39)),615, 610)))

  7. #7
    Registered User
    Join Date
    08-29-2013
    Location
    Kaunas, Lithuania
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Need help with finding text in a cell.

    These are steel pipes. 150x150x6x12000 are the dimensions and S355 shows how strong it is, therefore it is more expensive than 255. (610 instead of 562). If it is 355 and thicker (6mm instead of 5 or 4)the price goes to 615. This does not apply to S235. So:

    Quote Originally Posted by benishiryo View Post
    welcome to the forum n3xas. a better explanation would be to show the desired results for the different scenarios
    150x150x6x12000 S355
    contains both "x6x" & ends with 355. what should it show? 615?
    Yes, 615.

    150x150x5x12000 S355
    does not contain "x6x" & ends with 355. what should it show? 610?
    Yes, 610

    150x150x5x12000 S255
    does not contain "x6x" & ends with 255. what should it show? 562
    Yep.

    an explanation of the formula you have:
    =IF(ISNUMBER(SEARCH(235; B67)); 562; (IF(ISNUMBER(SEARCH(X6X;B67)); 615; 610)))
    if 235 is found anywhere in B67, put it as 562.
    the second search isn't valid because you need to put double quotes when searching for texts like "x6x". so if i put the double quotes, it will return 615 if "x6x" is found in B67
    only when the 2 tests fails, it will return 610. so changing it to this will work (if i assume correctly):
    =IF(ISNUMBER(SEARCH(235, B39)), 562, (IF(ISNUMBER(SEARCH("X6X",B39)),615, 610)))
    Thanks a lot, I will try that and let you know how it goes.

    EDIT: this did the trick, so I was only missing the quotes around X6X. Though I'm still a bit confused about ISNUMBER, can you use it in any similar situation or not. The description says it only checks if the value is a number, so how does it work here

    Anyway, thanks everyone.
    Last edited by n3xas; 08-30-2013 at 09:06 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. [SOLVED] Finding text in a cell
    By MrIdontknowexcel in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-22-2012, 07:45 PM
  2. UDF for finding text in cell from a list of text
    By tom.hogan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-26-2011, 10:14 AM
  3. Replies: 1
    Last Post: 01-11-2010, 12:31 PM
  4. Finding text in a cell
    By amitmodi_mrt in forum Excel General
    Replies: 11
    Last Post: 09-08-2009, 02:40 AM
  5. Finding text in a cell
    By Tom_Fernley in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-20-2008, 01:20 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