+ Reply to Thread
Results 1 to 6 of 6

Calculate date to required end of month

  1. #1
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Calculate date to required end of month

    Hi all.

    Using DateAdd("m", 3, Date), I can return a date exactly 3 months from the current date. No difficulty there, elegant and simple to expand on.

    I have a requirement, however, to return a specific date within a frame. e.g

    If the date falls between 1/1/16 and 31/03/2016, then the returned date must be 31/03/2016.
    If the date falls between 1/4/16 and 30/06/2016, then the returned date must be 30/06/2016.

    I am looking for a relatively elegant solution to this question. But it must be able to handle future years also. (e.g. 2016, 2017...2020, etc)

    Can anybody show me a way to do this.

    Cheers

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,033

    Re: Calculate date to required end of month

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Calculate date to required end of month

    Oh c'mon!!

    If you had to ask for a workbook then you didn't read the question. I also note that this is a generic response that you almost always copy/paste in your answers.

    The question is clearly presented and asked. It wastes my time and yours, and leads other to believe that somebody is helping with the issue, when they are in fact not.

    Please don't respond if you didn't read or understand this very clearly defined question.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,033

    Re: Calculate date to required end of month

    You have asked for a vba solution. How am I to know what columns you have data in, what rows that they start in? What specifically your spreadsheet looks like if you are not going to tell me in your post. I am not willing to throw darts blindfolded at your target without seeing it. If you believe you have provide all the necessary information to your request, then I disagree with you. As to further help, don't worry, I am putting you on my do not response list. You will no longer have to worry about my responses.

  5. #5
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: Calculate date to required end of month

    Oh C'mon guys! Don't get upset. Let's not forget why'we're here for.
    Throwing darts blindfolded at your target without seeing it here:
    First you have to take the month and year info from your date, right? (m = Month(...), y = Year(...)
    Then a simple if/elseif condition
    Please Login or Register  to view this content.
    Last edited by bulina2k; 01-13-2016 at 12:26 AM.
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  6. #6
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Calculate date to required end of month

    Alan, I apologise if my tone seemed a bit harsh, however, I had carefully considered the question when writing it, and since my question was specifically VBA related, did not at all believe that posting a book was relevant, or the request for one helpful.

    Thank you Bulinak. I appreciate the effort to understand the problem, and provide an example. I followed your example and used a select case instead of If then (mostly because I had more than two conditions)

    Please Login or Register  to view this content.
    This was the shortest way I could think to do this, and still uses Dateadd

    Cheers and take a rep for your response!

+ 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. Help required to calculate TAT date.
    By nirajisara in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-23-2015, 02:42 AM
  2. Replies: 14
    Last Post: 04-06-2015, 09:19 PM
  3. Replies: 0
    Last Post: 07-17-2014, 06:31 AM
  4. Replies: 1
    Last Post: 06-05-2014, 09:48 AM
  5. Formula required to calculate next month
    By Snowpear in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2013, 08:13 PM
  6. [SOLVED] Different dates but required of the first date of that month
    By PRADEEPB270 in forum Excel General
    Replies: 2
    Last Post: 09-23-2011, 06:43 AM
  7. Calculate month-end date from date in adjacent cell?
    By Matt D Francis in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-19-2005, 12:06 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