+ Reply to Thread
Results 1 to 4 of 4

if-statement inside an if-statement

  1. #1
    Registered User
    Join Date
    06-13-2009
    Location
    Albuquerque, New Mexico
    MS-Off Ver
    Excel 2000
    Posts
    6

    if-statement inside an if-statement

    If A1 shows 10:00am and A2 shows 4:00pm, then A3 calculates the total number of hours:

    =(A2-A1)*24


    But if A1 shows "Off," then A3 shows 0:

    =IF(A1="Off",0,(A2-A1)*24)


    Now, if I want to change "(A2-A1)*24" to another if-statement, how do I do this? I can always set up a hidden cell (A4) that contains the results of the first if-statement, and then say:

    =IF(A1="Off",0,A4)

    But can I do this without going through all the trouble of setting up hidden cells?

    Any ideas?
    Last edited by oldchippy; 06-18-2009 at 04:19 AM. Reason: Solved by OP

  2. #2
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097

    Re: if-statement inside an if-statement

    Hi,

    How about

    =IF(A1="Off",A4,(A2-A1)*24)
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: if-statement inside an if-statement

    Your post does not comply with Rule 5 of our Forum RULES. We have Seven question forums: Miscellaneous, General, Programming, Worksheet Functions, Charting, Excel 2007 Help and New Users. Please choose the appropriate forum, and post your question in ONLY one forum.

    Moved to Functions Forum
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    06-13-2009
    Location
    Albuquerque, New Mexico
    MS-Off Ver
    Excel 2000
    Posts
    6

    Re: if-statement inside an if-statement

    Actually, thank you but I figured it out on my own. Here's an example of one of my cells:

    =IF(D9="REQ",0,(IF(D9<=E9,(E9-D9)*24,0)))

+ 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.6.0 RC 1