+ Reply to Thread
Results 1 to 20 of 20

If statement to show 'N/A' or subtract dates

  1. #1
    Registered User
    Join Date
    10-12-2022
    Location
    Cardiff
    MS-Off Ver
    2016
    Posts
    26

    If statement to show 'N/A' or subtract dates

    Hi all,

    I am hoping someone can help me, my knowledge is not the best when it comes to if statement!

    I have attached some test data with a comments column showing the results I would like to see.


    IF status = CN storage only starts if delivered after 10 days from ETA
    IF status - PK storage only starts if delivered after 7 days from ETA

    If delivered within 10 days for CN - display N/A
    If delivered within 7 days for PK - display N/A


    I appreciate any help
    Last edited by smithnjs2988; 12-22-2022 at 07:27 AM. Reason: Advised by moderator

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,173

    Re: If Statements Help!!

    A sample sheet would help here

    The forum does allow for spreadsheets to be uploaded direct to the forum -

    Please see the Yellow Banner at the top of the page explaining how to attach a sample spreadsheet

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.

    Here are the instructions, found at the top of the page again
    Post a small Excel sheet (not a picture) showing realistic & representative sample data WITHOUT confidential information (10-20 rows, not thousands...) and some manually calculated results. For a new thread (1st post), scroll to Manage Attachments, otherwise scroll down to GO ADVANCED, click, and then scroll down to MANAGE ATTACHMENTS and click again. Now follow the instructions at the top of that screen.
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    10-12-2022
    Location
    Cardiff
    MS-Off Ver
    2016
    Posts
    26

    Re: If Statements Help!!

    Hi Wayne,


    I thought I attached the test data, just done it again

    Thanks,
    Attached Files Attached Files

  4. #4
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,173

    Re: If Statements Help!!

    how about
    =IF(AND(A2="CN",(C2-B2)>10),"Storage Starts "&TEXT(B2+10,"DD/MM/YYYY"),IF(AND(A2="PK",(C2-B2)>7),"storage Starts "&TEXT(B2+7,"DD/MM/YYYY"),"N/A"))

    only i make the PK - 7 days the 8th Not the 18th
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-12-2022
    Location
    Cardiff
    MS-Off Ver
    2016
    Posts
    26

    Re: If Statements - combining if, and or statements

    Hi Wayne,

    Wow quick work.

    That works great, thank you.

    One last thing, if I only want to display the storage date and remove the text, which part of the formula do I need to remove?

    Also, would it be possible to add if Del Field is blank and ETA is more than (7 days Pk or 10 days CN) in the past to display the display the date in the storage start date field?

    I hope this makes sense.

    Thanks
    Last edited by smithnjs2988; 12-21-2022 at 10:04 AM.

  6. #6
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,173

    Re: If Statements Help!!

    =IF(AND(A2="CN",(C2-B2)>10),B2+10,IF(AND(A2="PK",(C2-B2)>7),B2+7,"N/A"))

    make sure
    the cells / column are formatted as a date

    if cell del date is blank and tests are based as if Del date is today

    =IF(OR(AND(A2="CN",(C2-B2)>10),AND(A2="CN",C2="",(TODAY()-B2)>10)),B2+10,IF(OR(AND(A2="PK",(C2-B2)>7),AND(A2="PK",C2="",(TODAY()-B2)>7)),B2+7,"N/A"))

    see last entry row 9 where i have changed the eta date
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-12-2022
    Location
    Cardiff
    MS-Off Ver
    2016
    Posts
    26

    =IF(OR(Y2="N/A",(M2-Y2))) - help with forumla

    Great, thank you so much Wayne
    Last edited by smithnjs2988; 12-22-2022 at 06:27 AM. Reason: Updating Heading to be more meaningful

  8. #8
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,173

    Re: If Statements Help!!

    you are welcome
    Merry Xmas

  9. #9
    Registered User
    Join Date
    10-12-2022
    Location
    Cardiff
    MS-Off Ver
    2016
    Posts
    26

    Re: If Statements Help!!

    Hi Wayne,

    I tried adding another statement, but had an error when trying to add GB where the statement references PK, IS there a way to include both references in the same statement?

    =IF(OR(AND(A2="CN",(C2-B2)>10),AND(A2="CN",C2="",(TODAY()-B2)>10)),B2+10,IF(OR(AND(A2="PK",(C2-B2)>7),AND(A2="PK",C2="",(TODAY()-B2)>7)),B2+7,"N/A"))

  10. #10
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,173

    Re: If Statements Help!!

    add GB where the statement references PK
    can you provide more detail

    OR(AND(A2="PK",(C2-B2)>7),AND(A2="PK",C2="",(TODAY()-B2)>7))
    is this another OR , replacing PK with GB

    if so

    OR(AND(OR(A2="PK",A2="GB"),(C2-B2)>7),AND(OR(A2="PK",A2="GB"),C2="",(TODAY()-B2)>7))


    as below
    =IF(OR(AND(A2="CN",(C2-B2)>10),AND(A2="CN",C2="",(TODAY()-B2)>10)),B2+10,IF(

    OR(AND(OR(A2="PK",A2="GB"),(C2-B2)>7),AND(OR(A2="PK",A2="GB"),C2="",(TODAY()-B2)>7))

    ,B2+7,"N/A"))

  11. #11
    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. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,760

    Re: If Statements Help!!

    Administrative Note:

    We would very much like to help you with your query, however the thread title does not really convey what your request is about. Tell us what you are trying to do, not how you think it should be done.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    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.

  12. #12
    Registered User
    Join Date
    10-12-2022
    Location
    Cardiff
    MS-Off Ver
    2016
    Posts
    26

    Re: If Statements Help!!

    Hi Wayne,

    Sorry, I didn't give a clear explanation.

    Basically, I would like to edit the formula where it checks for PK to check for GB too and apply the same logic as PK.

    Thanks for all your help.

    P.S. can you recommend any tutorials as you can see i'm not very good with if statements

  13. #13
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,173

    Re: If Statements Help!!

    the formula i posted should do that
    it will check if PK OR if GB is in the cell and then it will apply the same logic , for PK or for GB

    Or if you nolonger wanted to have PK in the formula - just replace with GB

    this is more of a LOGIC issue rather than IF

    AND/OR/NOT/ functions

  14. #14
    Registered User
    Join Date
    10-12-2022
    Location
    Cardiff
    MS-Off Ver
    2016
    Posts
    26

    Re: =IF(OR(Y2="N/A",(M2-Y2))) - help with formula

    Hi Wayne,

    Me again, sorry!

    I have put this if statement together, but it's wrong.

    The results i want is, IF cell Y2 display's N/A display N/A or if it got a date subtract Y2 - M2

    =IF(OR(Y2="N/A",(M2-Y2)))

    Any help would be appreciated.
    Last edited by smithnjs2988; 12-22-2022 at 07:07 AM.

  15. #15
    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. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,760

    Re: If statement to show 'N/A' or subtract dates

    Thank you. The thread may now proceed.

  16. #16
    Registered User
    Join Date
    10-12-2022
    Location
    Cardiff
    MS-Off Ver
    2016
    Posts
    26

    Re: If statement to show 'N/A' or subtract dates

    Hi Wayne,

    Me again, sorry!

    I have put this if statement together, but it's wrong.

    The results i want is, IF cell Y2 display's N/A display N/A or if it got a date subtract Y2 - M2

    =IF(OR(Y2="N/A",(M2-Y2)))

    Any help would be appreciated.

  17. #17
    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. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,760

    Re: If statement to show 'N/A' or subtract dates

    Try this:

    =IF(ISNA(Y2),NA,M2-Y2)

  18. #18
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,173

    Re: If statement to show 'N/A' or subtract dates

    =IF( Y2="N/A", "N/A",M2-Y2)

    of if N/A is an error #N/A and NOT text N/A

    =IF( ISNA(Y2) , "N/A", M2-Y2)

  19. #19
    Registered User
    Join Date
    10-12-2022
    Location
    Cardiff
    MS-Off Ver
    2016
    Posts
    26

    Re: If statement to show 'N/A' or subtract dates

    Great, thanks both

  20. #20
    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. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,760

    Re: If statement to show 'N/A' or subtract dates

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

+ 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] If statements and Select statements in active controls userform
    By LaSouth1776 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-05-2020, 03:17 AM
  2. 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
  3. Reading If statements and formulating values from if statements
    By crnam in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-16-2013, 05:20 AM
  4. questions with if statements and nested if statements
    By Pat Excel in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 02-03-2013, 01:41 PM
  5. Multiple nested IF statements and AND statements
    By TonyGetz in forum Excel General
    Replies: 2
    Last Post: 12-14-2010, 03:07 AM
  6. Replies: 12
    Last Post: 05-15-2009, 08:38 AM
  7. [SOLVED] operator statements, shorting when reusing one of the statements?
    By KR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2005, 02:05 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