+ Reply to Thread
Results 1 to 11 of 11

Increase date by one month to end of month

  1. #1
    Registered User
    Join Date
    11-20-2019
    Location
    London
    MS-Off Ver
    Microsoft Office 365 V1910
    Posts
    81

    Increase date by one month to end of month

    Trying to write a code for a command button to increase the date on my worksheet by one month and return the end date of the month

    I wrote a really basic code;
    Please Login or Register  to view this content.
    When I increase to February it returns 29/02/2020
    Then when I go to March it returns 29/03/2020 and so on

    How can I amend it to return the end date of the month?
    Last edited by T.Turner; 02-12-2020 at 06:23 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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Increase date by one month to end of month

    Administrative Note:

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (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.
    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
    Registered User
    Join Date
    11-20-2019
    Location
    London
    MS-Off Ver
    Microsoft Office 365 V1910
    Posts
    81

    Re: Increase date by one month to end of month

    Hey Ali - All updated

  4. #4
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Increase date by one month to end of month

    Thanks.

    I know you want code, but the formula for this would be:

    =EOMONTH(EDATE(B1,1),0)

  5. #5
    Registered User
    Join Date
    11-20-2019
    Location
    London
    MS-Off Ver
    Microsoft Office 365 V1910
    Posts
    81

    Re: Increase date by one month to end of month

    Cheers,
    Yeah I have the formula, just can't work out how to apply it to code!

  6. #6
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Increase date by one month to end of month

    I thought that you could tell the code to apply a formula?

  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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Increase date by one month to end of month

    Something like this, for example:

    Please Login or Register  to view this content.
    https://docs.microsoft.com/en-us/off....range.formula
    Last edited by AliGW; 02-12-2020 at 06:37 AM.

  8. #8
    Registered User
    Join Date
    11-20-2019
    Location
    London
    MS-Off Ver
    Microsoft Office 365 V1910
    Posts
    81

    Re: Increase date by one month to end of month

    I can't seem to get it to work Ali - when I add the code, it writes the formula onto the document instead of increasing the date by a month and formatting to the end of the month.
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,913

    Re: Increase date by one month to end of month

    Or try:

    Please Login or Register  to view this content.

  10. #10
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: Increase date by one month to end of month

    How about this?

    Please Login or Register  to view this content.
    You no longer need the DateAdd line in your code.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  11. #11
    Registered User
    Join Date
    11-20-2019
    Location
    London
    MS-Off Ver
    Microsoft Office 365 V1910
    Posts
    81

    Re: Increase date by one month to end of month

    Please Login or Register  to view this content.
    That's working 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. Month on Month Increase %
    By Rushendra in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-20-2018, 08:28 AM
  2. Replies: 2
    Last Post: 08-16-2017, 02:11 AM
  3. Replies: 8
    Last Post: 07-13-2015, 01:39 PM
  4. Replies: 1
    Last Post: 07-06-2015, 04:43 PM
  5. Month over Month formula to show increase or decrease in rankings for SEO
    By lindsbay in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-12-2014, 03:03 AM
  6. Replies: 5
    Last Post: 10-04-2012, 07:06 AM
  7. [SOLVED] Excel month dropdown list to generate day of week and date for selected month
    By aaaaaaaa in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-17-2010, 02:45 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