+ Reply to Thread
Results 1 to 9 of 9

Need Year to be Variable in Formula

  1. #1
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2003
    Posts
    5

    Question Need Year to be Variable in Formula

    D6 contains a date - April 6, 2014 - this date will automatically change to a new day in 2015 and so on for every new year (it is a floating holiday date, Good Friday).

    G6 contains a number - 75.

    I want to have the number in G6 replicated in A3 if the date in D6 is greater than or equal to April 1 and less than or equal to April 15.

    This is the formula I have which works for 2014 but will not work when the year changes to 2015 and so on:

    =IF(AND(D6>=DATE(2014,4,1),D6<=DATE(2014,4,15)),G6,0)

    How can I make the year in the formula a variable so that it will look between April 1 and April 15 for any year?

    Thank you.

  2. #2
    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,938

    Re: Need Year to be Variable in Formula

    Hi and welcome to the forum

    Maybe this...

    =IF(AND(D6>=DATE(year(today()),4,1),D6<=DATE(year(today()),4,15)),G6,0)

    If you have a lot of these, it would be better to put TODAY() in its own cell, and then reference it. TODAY is a volatile function, and recalc with every workbook change - it may start slowing things down
    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

  3. #3
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2003
    Posts
    5

    Smile Re: Need Year to be Variable in Formula

    Thank you for the speedy reply.

    I will need to use the formula in 6 places in my workbook. I will test it out and let you know if it works as needed.

    Again, thank you!

  4. #4
    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,938

    Re: Need Year to be Variable in Formula

    IF only 6, then use as suggested, you wont need to reference it

  5. #5
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Need Year to be Variable in Formula

    Hi Ford

    Well it works for a portion of what I need but I have a glitch. The workbook spans a fiscal year of April to March so a portion of the workbook is in the current year and a portion is in the following year. Is there a way to make it look at the current year plus 1?

    Jada

  6. #6
    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,938

    Re: Need Year to be Variable in Formula

    That would be...
    DATE(year(today()+1)
    But I doubt that will let you span years - by itself. If you will be looking at a full year - or even full months - see if EDATE(Date,months) might help The months can be + (ahead) or - (in the past)

  7. #7
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Need Year to be Variable in Formula

    Hi Ford

    I have worked around the glitch by realizing I goofed - forgot to change the reference year for the holiday calculations to the next year - I am a novice after all. Thank you so much for your help. It was the last thing I needed to finish my payroll workbook.

    Jada

  8. #8
    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,938

    Re: Need Year to be Variable in Formula

    It was a pleasure assisting you, and thanks for the feedback

    I will mark this thread solved for you, for future reference, you can mark your threads solved by using the Thread Tools just above your 1st post

  9. #9
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Need Year to be Variable in Formula

    Thank you for marking it solved and goodnight.

+ 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] Keeping a date as current year, even though formula determines previous year
    By dropanddrive03 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-28-2013, 08:31 PM
  2. Replies: 0
    Last Post: 11-23-2012, 01:27 AM
  3. Replies: 3
    Last Post: 07-05-2012, 01:49 AM
  4. Replies: 0
    Last Post: 09-12-2009, 11:07 AM
  5. Replies: 3
    Last Post: 03-12-2009, 09:54 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