+ Reply to Thread
Results 1 to 5 of 5

Problem with using istext in a nested IF function

  1. #1
    Registered User
    Join Date
    07-02-2013
    Location
    ireland
    MS-Off Ver
    Excel 2010
    Posts
    21

    Problem with using istext in a nested IF function

    Hi,

    I'm a novice excel user and have a problem with a formula I tried,

    I have a worksheet and if cell a2 is blank then I want b2 to be blank. If a2 is text then I want certain text displayed in b2. However the text displayed in b2 depends on what is in b1, example if b1=5 and a2 has text then b2 says "five times", if b1=4 and a2 has text then b2 says "four times", if b1=3 and a2 has text the then b2 says "three times" etc. Again if there is no text in a2 then b2 stays blank, there will always be a number in b1 but it doesn't matter unless a2 has text in it.

    I'm not sure how to write the formula, I've tried this one =IF(ISTEXT(a2),IF(b1=5,"five times",IF(b1=4,"four times",IF(b1=3,"three times",IF(b1=2,"twice",""))))))

    This one kind of works but I get false displayed in b2 every time a2 is empty, I presume I making a mistake somewhere,

    I'd be grateful if anyone could help
    Thanks

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Problem with using istext in a nested IF function

    Hi and welcome to the forum

    You did not include a test for blank...
    =if(A2="","",IF(ISTEXT(a2),IF(b1=5,"five times",IF(b1=4,"four times",IF(b1=3,"three times",IF(b1=2,"twice","")))))))

    An alternative to this would be to create a small table with the value and the corresponding text in it. then you could use a simple vlookup() to pull in the text. Something like...
    =if(A2="","",vlookup(A2,$C$2:$D$4,2,0))

    where C2:D4 contains the value (2,3,4,5 etc) and the text (Twice, three etc)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Problem with using istext in a nested IF function

    although there are nested ifs


    IF(B1=5,"five times",IF(B1=4,"four times",IF(B1=3,"three times",IF(B1=2,"twice","")))) is a stand alone and is complete and is used as the TRUE part of the formula
    =IF(ISTEXT(A2),true,false)
    so you need to include the false part

    =IF(ISTEXT(A2),true,"")
    then add in the TRUE bit

    =IF(ISTEXT(A2),IF(B1=5,"five times",IF(B1=4,"four times",IF(B1=3,"three times",IF(B1=2,"twice","")))),"")
    this will give blank if a2 isnt text
    you could also use
    =IF(ISTEXT(A2),IF(B1<2,"",CHOOSE(B1-1,"twice","three times","four times","five times")),"")
    Last edited by martindwilson; 08-08-2013 at 07:59 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Registered User
    Join Date
    07-02-2013
    Location
    ireland
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Problem with using istext in a nested IF function

    Thanks Guys, both solutions worked! Much appreciated!

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Problem with using istext in a nested IF function

    Happy to help and thanks for the feedback

+ 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. IF(ISTEXT nested statement - Please Help
    By dimi1963 in forum Excel General
    Replies: 7
    Last Post: 08-02-2012, 02:47 PM
  2. Nested IF and ISTEXT Statments
    By Kwarren in forum Excel General
    Replies: 6
    Last Post: 01-15-2011, 03:21 PM
  3. Help on conditional IF statement nested with ISTEXT.
    By DorothyFan1 in forum Excel General
    Replies: 4
    Last Post: 12-31-2010, 05:03 AM
  4. Excel 2008 : problem ISTEXT with ranges?
    By so_fistica_ted in forum Excel General
    Replies: 8
    Last Post: 06-08-2010, 08:03 AM
  5. Sumproduct Or Istext Function Problem
    By andyp161 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-04-2007, 12:28 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