+ Reply to Thread
Results 1 to 7 of 7

Need help with If AND statements

  1. #1
    Registered User
    Join Date
    03-08-2011
    Location
    Tampa
    MS-Off Ver
    Excel 2007
    Posts
    6

    Need help with If AND statements

    Hi guys,

    I have a large data set and i need to add which year they belong to. For example, if a range is between 1/1/08 and 12/31/08 it needs to be in 2008 and if it is between 1/1/09 and 12/31/09 it needs to be in year 2009 and if it is between 1/1/10 and 12/31/10 then it needs to be in year 2010. Can someone please help me with the code that would work for this scenario. Thanks in advance.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Need help with If AND statements

    By "I need to add which year they belong to" do you want to separate your data into separate spreadsheets by year? If you just want a column with the year (which you can sort),
    =YEAR(A2) where Column A is where your date is. New column should be formatted as General.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    03-08-2011
    Location
    Tampa
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Need help with If AND statements

    Hey thanks for the reply. I have several workbooks in a single spreadsheet and i need to add a year column based on the date ranges.

    For example my dates look like this:
    10/1/2006
    2/3/2007
    8/26/2008
    9/30/08
    2/11/2009
    10/17/2009 and so forth.

    What i need is to create a formula that places the first two dates in year 2007; the next two dates in 2008; the next date in 2009 and the last date in 2010.

    Hope this explanation helps. Thanks

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Need help with If AND statements

    Did you try my formula?

  5. #5
    Registered User
    Join Date
    03-08-2011
    Location
    Tampa
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Need help with If AND statements

    Quote Originally Posted by ChemistB View Post
    Did you try my formula?
    Yes but that doesn't work because I need a range of dates.

    Dates 10/1/08 - 9/30/09 belong in year 2009
    Dates 10/1/09 - 9/30/10 belong in year 2010
    Dates 10/1/10 - 9/30/10 belong in year 2011

    I need a formula for that. Thanks

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Need help with If AND statements

    I think an example workbook would help me (Go Advanced>Manage Attachments). I can't figure out if you want the minimum and max date for each year (the range) or something else? Also, in post #3, you put 10/1/2006 into 2007 and in post #5, you put 10/1/08 into 2009. Are these typos?

    If you post an example workbook, show how your data is set up and what you want your results to look like. Thanks

  7. #7
    Registered User
    Join Date
    03-08-2011
    Location
    Tampa
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Need help with If AND statements

    Quote Originally Posted by ChemistB View Post
    I think an example workbook would help me (Go Advanced>Manage Attachments). I can't figure out if you want the minimum and max date for each year (the range) or something else? Also, in post #3, you put 10/1/2006 into 2007 and in post #5, you put 10/1/08 into 2009. Are these typos?

    If you post an example workbook, show how your data is set up and what you want your results to look like. Thanks
    Thanks for the help but i cannot post it for you because its from work and its confidential. As for the range of dates, the one in post 5 is correct.

+ 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