+ Reply to Thread
Results 1 to 5 of 5

Thread: Two conditional formulas in one cell

  1. #1
    Registered User
    Join Date
    03-31-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Two conditional formulas in one cell

    Hi,

    Thanks in advance for your help!

    I am trying to write a formula so that:

    if J9<10, display 00000
    if J9 is between 10 and 99, display 0000
    if J9 is 100-999, display 000
    if J9 is 1000-9999, display 00
    if J9 is 10000-99999, display 0
    if J9>99999, the cell is blank (Note, it will be okay if this last one is not possible)

    So far I have IF(AND(J9>9,J9<100),"0000","000")

    So it works for numbers between 10-999 right now.

    Can anyone tell me how to do this? I really appreciate your time and help!
    Last edited by NBVC; 04-02-2009 at 03:44 PM.

  2. #2
    Forum Guru ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    traded up
    MS-Off Ver
    2003 & 2010
    Posts
    1,905

    Re: Two conditional formulas in one cell

    Try this:

    =IF(J9<10,"00000",IF(AND(10<=J9,J9<=99),"0000",IF(AND(100<=J9,J9<=999),"000",IF(AND(1000<=J9,J9<=9999),"00",IF(AND(10000<=J9,J9<=99999),"0","")))))
    HTH
    “To sin by silence when they should protest makes cowards of men.” ~ Abraham Lincoln

  3. #3
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Two conditional formulas in one cell

    Try:

    =LOOKUP(J9,{0,10,100,1000,10000,100000},{"00000","0000","000","00","0",""})
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  4. #4
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,780

    Re: Two conditional formulas in one cell

    =choose(len(j9),"00000","0000","000","00","0","",)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and a dabbler in Cisco
    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

  5. #5
    Registered User
    Join Date
    03-31-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Two conditional formulas in one cell

    Thank you ConneXionLost and NBVC for your replies

    I tried ConneXionLost's formula and it worked perfectly. I have been trying to figure this out for awhile and I am so happy to have it done!

    Thanks again for taking the time to reply.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0