+ Reply to Thread
Results 1 to 10 of 10

How to do an if statement for a set of numbers?

  1. #1
    Registered User
    Join Date
    08-11-2022
    Location
    United Kingdom
    MS-Off Ver
    365
    Posts
    4

    How to do an if statement for a set of numbers?

    Suppose I want to apply a particular effect if the month is February, March, April, May, June, September, November or December. I do not wish to apply this if the month is January, July or August.

    How would I do this? I tried something like IF(MONTH(cell)=[2,3,4,5,6,9,10,11,12]), but I don't think I know the correct Excel syntax or maybe there's a better way to do this.

    Thanks,

    Danny
    Last edited by inferno657; 07-24-2023 at 07:41 AM.

  2. #2
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,461

    Re: How to do an if statement for a set of numbers?

    Try:

    =IF(AND(MONTH(cell)<>1,MONTH(cell)<>7,MONTH(cell)<>2),...)
    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.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,201

    Re: How to do an if statement for a set of numbers?

    Don't you actually mean OR, not AND???

    =IF(OR(MONTH(cell)<>1,MONTH(cell)<>7,MONTH(cell)<>2),...)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,124

    Re: How to do an if statement for a set of numbers?

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

  5. #5
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,461

    Re: How to do an if statement for a set of numbers?

    Quote Originally Posted by Glenn Kennedy View Post
    Don't you actually mean OR, not AND???

    =IF(OR(MONTH(cell)<>1,MONTH(cell)<>7,MONTH(cell)<>2),...)
    No, I ment what I said. Try it with OR - won't work.

    OR will return TRUE for all dates. AND returns FALSE for dates in January, July or February.
    Last edited by AliGW; 07-24-2023 at 07:17 AM.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,201

    Re: How to do an if statement for a set of numbers?

    I just did try it... and you are 100% correct.

  7. #7
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,461

    Re: How to do an if statement for a set of numbers?

    LOL, Glenn - I've had more experience with AND and OR than I'd care to admit ...

  8. #8
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: How to do an if statement for a set of numbers?

    Or try

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by HansDouwe; 07-24-2023 at 07:33 AM.

  9. #9
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,461

    Re: How to do an if statement for a set of numbers?

    That's a nice option, Hans.

  10. #10
    Valued Forum Contributor
    Join Date
    06-23-2021
    Location
    Romania
    MS-Off Ver
    2021, 365 v 2208
    Posts
    722

    Re: How to do an if statement for a set of numbers?

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

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


    If the solutions offered helped you to solve your problem, then mark the thread as SOLVED (thread tools in the top menu) and you can click on * to add reputation to those who helped you, as a way to say thank you !

+ 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 then statement for extracting numbers
    By MaartenRo in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-17-2022, 01:14 AM
  2. [SOLVED] If statement for value between two numbers
    By Khalil Handal in forum Excel General
    Replies: 2
    Last Post: 06-25-2021, 11:37 AM
  3. If statement between numbers
    By araza123 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-26-2019, 06:15 PM
  4. [SOLVED] Using letters instead of numbers in an 'if' statement?
    By natbat78 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-20-2014, 10:21 AM
  5. If statement help with numbers
    By cobydobbs in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-27-2013, 05:00 PM
  6. nested if statement with i between numbers
    By rbpd5015 in forum Excel General
    Replies: 4
    Last Post: 08-18-2010, 12:35 PM
  7. [SOLVED] IF than statement in a range of numbers? please help?
    By AC man in forum Excel General
    Replies: 10
    Last Post: 01-09-2006, 06:40 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