+ Reply to Thread
Results 1 to 12 of 12

Multiple If Statements - How to Streamline

Hybrid View

  1. #1
    Registered User
    Join Date
    05-05-2019
    Location
    Atyrau, Kazakhstan
    MS-Off Ver
    Office 365
    Posts
    6

    Multiple If Statements - How to Streamline

    Hello All,

    New member, and I'm definitely a novice at Excel. Vlookups and statements off of this are about as detailed as I have gotten before, which brings me to my issue.

    I have a large spreadsheet that looks up a value, then must go to another sheet to look up and see if the spreadsheet matches 3 criteria in each row. There it takes about 4 hours to calculate with all the inefficiencies. I was wondering if anyone could help clean this up with a better formula. There are 340K of these formulas just like this in the sheets on the spreadsheet...thus the issue.


    {=IF(MAX(IF(Staging!$A:$A=$A3,ROW(Staging!$A:$A))*IF(Staging!$B:$B<=KN$1,ROW(Staging!$B:$B))*IF(Staging!$C:$C>=KN$1,ROW(Staging!$C:$C)))>0,"N","Y")}

    Staging A:A (1,700 Rows) shows the value that I am trying to match in this sheet's A3 (Call the value in A3 "T7000").
    Next it looks to see if the date in Column B (start date) is less than or equal the date in this cell column's header,
    Then it looks to see if the date in Column C is greater than or equal to the next column's date in it's header,
    Finally, If this is true (if the start and/or finish dates run during or through the above range), then it returns No if it is in the range to show the equipment is shut down for repairs and Yes if it is running (unaffected).


    Any help you can provide is great, and thank you!
    Attached Files Attached Files
    Last edited by pmdave73; 05-06-2019 at 04:06 AM.

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

    Re: Multiple If Statements - How to Streamline

    Welcome to the forum!

    Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    05-05-2019
    Location
    Atyrau, Kazakhstan
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Multiple If Statements - How to Streamline

    I will post a Sample shortly, and I understand. Thanks for the advice AliGW!

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

    Re: Multiple If Statements - How to Streamline

    I cannot see the formula in your workbook. Where are the expected results?

  5. #5
    Registered User
    Join Date
    05-05-2019
    Location
    Atyrau, Kazakhstan
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Multiple If Statements - How to Streamline

    My apologies, I saved the spreadsheet but was in column EO when I saved it. Results are on the Output Tab in Cells B3 through AE6 as a sample.

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

    Re: Multiple If Statements - How to Streamline

    Could an item appear more than once on the Staging list?

    You should first try limiting the ranges in the formula. Whole column references can cause massive overheads. Turn your staging table into a proper Excel table and then use the table references instead. See if that helps.

    =IF(MAX(IF(Table1[Equipment Name]=$A3,ROW(Table1[Equipment Name]))*IF(Table1[Start]<=B$1,ROW(Table1[Start]))*IF(Table1[Finish-Calc]>=B$1,ROW(Table1[Finish-Calc])))>0,"N","Y")
    Last edited by AliGW; 05-06-2019 at 01:07 AM.

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

    Re: Multiple If Statements - How to Streamline

    Let us know what happens when you have tried my suggestion, please.

  8. #8
    Registered User
    Join Date
    05-05-2019
    Location
    Atyrau, Kazakhstan
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Multiple If Statements - How to Streamline

    Will do! Thanks again! If it runs better in the full version, I will mark this as solved. Much appreciated again for your time and efforts!

  9. #9
    Registered User
    Join Date
    05-05-2019
    Location
    Atyrau, Kazakhstan
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Multiple If Statements - How to Streamline

    "Could an item appear more than once on the Staging list?"

    Yes, the "staging data" is a data dump of each piece of equipment over the next 6 years for maintenance/compliance, and of rebuild work. So each piece of equipment (there are about 400 pieces of equipment/rows that we track on the Output sheet) will appear raw data numerous times. There are about 4,000 rows in the raw data for whenever we will have an outage fed from our planning system.


    These data outputs are then fed to a model that runs with various pressures/variants, and spits out a forecast. We are trying to use Excel to proofread our data, and make sure we aren't shutting down multiple pieces of equipment at the same time that all are on high production systems, which will result in high production loss overall...and catch these before they go in to the model from our dataset (the Model takes about 24 hours to run using an AI cluster).

    Thank you very much for your Input, AliGW. I will try to minimize the cells this is searching through and try to do the cleanup that you suggest on the Input side.

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

    Re: Multiple If Statements - How to Streamline

    Excellent.

  11. #11
    Registered User
    Join Date
    05-05-2019
    Location
    Atyrau, Kazakhstan
    MS-Off Ver
    Office 365
    Posts
    6

    Thumbs up Re: Multiple If Statements - How to Streamline

    So....the test results are in. You were correct...cleaning things up and putting finite cells rather than selecting the entire column, I ran it on 4 pieces of equipment for testing. It went from 5 minutes 16 seconds to calculate. After the cleanup, it took just under 5 seconds to calculate!


    Thanks so much Ali! Looks like I have a bad habit I need to get rid of. Never noticed it in old Excel I guess when we had 65K rows max...but when the formulae get more statements and you add 1 Million+ rows it makes a huge difference!

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

    Re: Multiple If Statements - How to Streamline

    Yes, a VERY bad habit! If you use tables, as I suggested, then your ranges will become dynamic.

    Glad to have helped!

+ 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. [SOLVED] Multiple If statements with multiple then statements pulling from Index/Match commands
    By Reggie Wells in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-30-2017, 03:25 PM
  2. [SOLVED] Nested if statements containing multiple and statements
    By John M. in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-22-2014, 11:48 PM
  3. Formula with multiple IF statements and IF AND statements
    By lottidotti in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-14-2013, 08:03 AM
  4. Excel 2007 : How do I streamline this?
    By ChrisLehrich in forum Excel General
    Replies: 5
    Last Post: 10-16-2011, 01:17 PM
  5. Help to streamline my code.
    By gpwaters in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-21-2011, 02:55 PM
  6. Multiple nested IF statements and AND statements
    By TonyGetz in forum Excel General
    Replies: 2
    Last Post: 12-14-2010, 03:07 AM
  7. Replies: 12
    Last Post: 05-15-2009, 08:38 AM

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