+ Reply to Thread
Results 1 to 25 of 25

Need help with IF statement

  1. #1
    Forum Contributor
    Join Date
    06-02-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    235

    Need help with IF statement

    I have a formula with may IF statements and* I need this to work in Excel 2000. The issue is I have this formula and it works fine in Excel 2000
    *
    WORKS
    *When I try to add just 1 more If to this (more than 8) It will give me an error in Excel 2000.*
    *
    DOESN'T WORK IN EXCEL 2000
    *
    =IF(V15="#'S",$A$355,IF(V15="INV",$A$354,IF(V15="OP INV",$A$355IF,IF(V15="OP",$A$355,IF(V15="REQ OP",$A$355,IF(V15="MID",$A$356,IF(V15="REQ MID",$A$356,IF(V15="CL",$A$357,IF(V15="REQ CL",$A$357,""))))))))
    *
    Does anyone know of a way to write the 2nd formula having 8 or more IF's?
    Last edited by g1terra; 05-30-2017 at 12:22 AM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,165

    Re: Need help with IF statement

    Hi g1terra,

    Instead of using multiple If statements, look at using VLookup instead.

    https://www.howtogeek.com/howto/1378...okup-in-excel/

    If you can attach a sample workbook we can show you "exactly" how to use it.


    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Need another way to write OF statement (more than 8)

    there is a maximum of the amount of IF statements you can nest which is 7

    why dont you just have a table to vlookup what it should do when has any of those values?
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  4. #4
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Need another way to write OF statement (more than 8)

    This should work, but it's pretty brute-force:
    =IF(OR(V15="#'S",V15="OP INV",V15="OP",V15="REQ OP"),$A$355,IF(V15="INV",$A$354,IF(OR(V15="MID",V15="REQ MID"),$A$356,IF(OR(V15="CL",V15="REQ CL"),$A$357,""))))

    ps: A slightly tighter version, added later:
    =IF(OR(V15={"#'S","OP INV","OP","REQ OP"}),$A$355,IF(V15="INV",$A$354,IF(OR(V15={"MID","REQ MID"}),$A$356,IF(OR(V15={"CL","REQ CL"}),$A$357,""))))


    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Last edited by leelnich; 05-30-2017 at 07:36 AM.

  5. #5
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Need another way to write OF statement (more than 8)

    awww i did the brute force too...but too slow

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    its slightly different =p
    i have INV in the 3rd IF

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,277

    Re: Need help with IF statement

    As there were already responses in both threads, I have merged your duplicate threads. In future, please do NOT start more than one thread per issue. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  7. #7
    Forum Contributor
    Join Date
    06-02-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    235

    Re: Need help with IF statement

    Ok here is a copy.

    I started it on P1 and highlighted the 1st sequence I have to copy the formula to in orange. The issue with using the VLOOKUP vs IF statements is I need this schedule to know each version of the Opening Shift (Ex OP, OP INV, REQ OP). But what makes this not work is I also need to be able to manually overwrite formula (instead of always selecting using drop down) to add the shift times. When I use VlOOKUP and manually overwrite these populated shift times it comes out as a date format I need to show as text. (ex 10-8) not Oct-8

    Sorry the file is 3MB but saying upload failed..
    Last edited by g1terra; 05-30-2017 at 02:09 AM.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,277

    Re: Need help with IF statement

    There is no file attached ...

  9. #9
    Forum Contributor
    Join Date
    06-02-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    235

    Re: Need help with IF statement

    Lets try this again..
    Last edited by g1terra; 05-30-2017 at 01:18 PM.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,277

    Re: Need help with IF statement

    To manually enter this sort of string you need to precede it with an apostrophe (') to prevent Excel from reading it as a date. So, to get 10-8, you must actually type '10-8.

  11. #11
    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,926

    Re: Need help with IF statement

    Or, format the cell as text 1st
    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

  12. #12
    Forum Contributor
    Join Date
    06-02-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    235

    Re: Need help with IF statement

    Yes I know this but the people using my sheet will not. Is there a way of displaying the cell that auto populated as text so they wont have to do this? (use the ')

  13. #13
    Forum Contributor
    Join Date
    06-02-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    235

    Re: Need help with IF statement

    If i format the cell as text the formula that auto populated will not show result?

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,277

    Re: Need help with IF statement

    As Ford has said above, pre-format cells as text.

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,277

    Re: Need help with IF statement

    Quote Originally Posted by g1terra View Post
    If i format the cell as text the formula that auto populated will not show result?
    It seems to continue working here. It's not a calculation, just a lookup, so there is no reason why changing the format in this instance will break it.

  16. #16
    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,926

    Re: Need help with IF statement

    Quote Originally Posted by g1terra View Post
    Yes I know this but the people using my sheet will not. Is there a way of displaying the cell that auto populated as text so they wont have to do this? (use the ')
    Format the whole range as text, they wont see any difference and entries will be accepted correctly

  17. #17
    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,926

    Re: Need help with IF statement

    Quote Originally Posted by g1terra View Post
    If i format the cell as text the formula that auto populated will not show result?
    OK, you have said the user is entering data into the cell, now you are saying there will be a formula. - which is it?

  18. #18
    Forum Contributor
    Join Date
    06-02-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    235

    Re: Need help with IF statement

    ok let me try again thx for checking!~

  19. #19
    Forum Contributor
    Join Date
    06-02-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    235

    Re: Need help with IF statement

    Did you look at the sheet I attached? The orange highlighted fields will auto Populate (using drop down list). I want to reserve the option for them to overwrite the formula and type text in. The Vlookup I am using is not working like it should for some reason. Can you open this sheet to see what I am talking about.

  20. #20
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,165

    Re: Need help with IF statement

    Hi g1terra,

    I'm looking at your sheet and at cell V13 on the sheet named "P1". This cell is merged with U13. Because U13 and V13 are merged, it looks like U13 and/or V13 are equal to "REQ OP". V13 really has nothing in it. This makes your VLookup formula a problem as you are asking to match a blank cell. Try this formula in U14:

    Please Login or Register  to view this content.
    I think the merged cells in your design of your worksheet is confusing us all.

  21. #21
    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,926

    Re: Need help with IF statement

    Quote Originally Posted by g1terra View Post
    Did you look at the sheet I attached? The orange highlighted fields will auto Populate (using drop down list). I want to reserve the option for them to overwrite the formula and type text in. The Vlookup I am using is not working like it should for some reason. Can you open this sheet to see what I am talking about.
    I can find no file attached

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.

  22. #22
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,277

    Re: Need help with IF statement

    The file was attached to post #9 - it seems the OP removed it last evening.

  23. #23
    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,926

    Re: Need help with IF statement

    Thats probably why I cant find it, but if OP removed file, why ask if we looked at it lol?

  24. #24
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,277

    Re: Need help with IF statement

    He asked that question roughly 9 hours before he removed the file. Maybe he just gave up on the thread? Some members don't seem to grasp the time zones at play here. Hopefully he'll see these new posts and replace the file.

  25. #25
    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,926

    Re: Need help with IF statement

    we can but hope

+ 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. Replies: 2
    Last Post: 07-09-2015, 04:25 PM
  2. [SOLVED] If statement to select data - nested statement - assistance
    By petitesouris in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-29-2015, 09:55 PM
  3. compile error expected line number statement end statement
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2014, 10:12 AM
  4. VBA Compile Error : line number or label or statement or end of statement
    By excellearner121 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2013, 06:41 PM
  5. Replies: 4
    Last Post: 06-01-2012, 10:05 AM
  6. Replies: 4
    Last Post: 05-16-2012, 05:33 PM
  7. [SOLVED] Utilize a Select Case Statement in Target Intersect Statement
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2009, 08:55 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