+ Reply to Thread
Results 1 to 12 of 12

IF cell contains a certain item of text then display result

  1. #1
    Registered User
    Join Date
    12-23-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    15

    IF cell contains a certain item of text then display result

    Hi Folks,

    I'm trying to create a spreadsheet that will look to see if a cell starts with a certain number and then it should look within the cell to see if it contains a "-" (dash) and display a result depending on whether there is a dash in it or not.

    A bit more in depth,
    The data provided is normally an 8 digit number beginning with a 2 (e.g. 23456789), however, sometimes it can be a number that begins with a 3 and typically contains a (dash) followed by a further two digits (e.g. 34567890-12). I need to be able to search for anything that begins with a 3 and display anything before the dash in one cell and anything after the dash in another cell.
    So far I've been using the below formulas to get this:

    =IF(LEFT(B3,1)="3",LEFT(B3,8),"")
    =IF(LEFT(B3,1)="3",RIGHT(B3,2),"")

    However, some of the data I'm using appears to not have a dash and the digits that should follow it which is causing my formulas to show incorrect results. What I'm wanting to do is search in the cell to see if it contains a dash and if it does pull through the data from after that dash into the cell, but if it doesn't then enter "10" into the cell.

    I've attached a copy of the spreadsheet I've been using.

    Hope someone can help! and that this actually makes sense!

    L.

    Test.xls

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: IF cell contains a certain item of text then display result

    =IF(B3="","",IF(AND(LEFT(B3,1)="3",NOT(ISERROR(FIND("-",B3,1)))),RIGHT(B3,2),""))

    Maybe that for your G column.

  3. #3
    Registered User
    Join Date
    12-23-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF cell contains a certain item of text then display result

    Hi yudlugar,

    Thanks for your prompt response. I've tried inputting that and while it works for the data that begins with a 3 and has no dash, it doesn't work for when the data does contain a dash and then when the cell is blank it is pulling through "10" when I would prefer it to stay blank...

    Any other suggestions?

    L.

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: IF cell contains a certain item of text then display result

    I think maybe you have the cell row references "out of sync?"

    See attachment as an example
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-23-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF cell contains a certain item of text then display result

    Hi yudlugar,

    That seems to have worked! Many thanks for your help!

    L.

  6. #6
    Registered User
    Join Date
    12-23-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF cell contains a certain item of text then display result

    apologies yudlugar,

    it doesn't appear to have worked afterall.

    It is not automatically putting in the 10 if there is no dash...

    L.

  7. #7
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: IF cell contains a certain item of text then display result

    Sorry, didn't see that requirement
    =IF(B3="","",IF(AND(LEFT(B3,1)="3",NOT(ISERROR(FIND("-",B3,1)))),RIGHT(B3,2),10))

  8. #8
    Registered User
    Join Date
    12-23-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF cell contains a certain item of text then display result

    No worries,

    I've tried adding that in but it is now showing 10 all the time no matter if the original data begins with a 2 or 3 and has no dash... Ideally it should remain blank unless it begins with a 3 and there is no dash..

    Sorry for being a nuisance!

    L.

  9. #9
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: IF cell contains a certain item of text then display result

    =if(and(b3="",not(left(b3,1)="3")),"",if(iserror(find("-",b3,1)),right(b3,2),10))
    ?

  10. #10
    Registered User
    Join Date
    12-23-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF cell contains a certain item of text then display result

    Sorry still no luck with that one.

    /l.

  11. #11
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: IF cell contains a certain item of text then display result

    Last go:
    =IF(OR(B3="",NOT(LEFT(B3,1)="3")),"",IF(ISERROR(FIND("-",B3,1)),10,RIGHT(B3,2)))

  12. #12
    Registered User
    Join Date
    12-23-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF cell contains a certain item of text then display result

    I'm pretty sure that's it now!

    Thank you very much!

+ 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. Display formula result if cell is X cells away from text value
    By jimmygig in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-29-2013, 08:30 PM
  2. Display numerical result of a cell with Text as well
    By davidcrawt in forum Excel General
    Replies: 3
    Last Post: 11-26-2012, 03:27 PM
  3. Disable Solver Result Dialog Box & Display Result in Cell
    By yauchildchew in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-04-2010, 01:46 PM
  4. display SUM result and TEXT together
    By XLS-EXCEL in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-15-2008, 12:50 PM
  5. user form question: text box to display result
    By BigPig in forum Excel General
    Replies: 0
    Last Post: 02-27-2006, 08:40 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