+ Reply to Thread
Results 1 to 6 of 6

coding for incrementing date by 1 month

  1. #1
    Forum Contributor
    Join Date
    08-04-2010
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    143

    coding for incrementing date by 1 month

    Hi all,

    i have a simple question. i would like to increase the month by one. i know that there is the "dateadd" function. however, coding error "type mismatch" occurs when i tried to run the macro.

    this is what i had done:
    Please Login or Register  to view this content.
    current month : sep10
    next month : oct10 (results from using macro)

    i am pretty sure that the coding for this is very straightforward but i cant seem to find any solution online. any help would be greatly appreciated
    Last edited by dan2010; 09-14-2010 at 04:14 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: coding for incrementing date by 1 month

    Try just:

    Please Login or Register  to view this content.

    and then just format the cells as you require.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Contributor
    Join Date
    08-04-2010
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    143

    Re: coding for incrementing date by 1 month

    i have managed to get "sep10" with
    Please Login or Register  to view this content.
    however for the value of the next month, it shows "Oct-10" instead of "oct10" with
    Please Login or Register  to view this content.
    do u have any suggestions how can i change the format of the date to "oct10"?

    thanks

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: coding for incrementing date by 1 month

    You'll need to format the cells as text I think otherwise Excel will try and help out by converting what it sees as dates to serial date values:

    Please Login or Register  to view this content.

    Dom

  5. #5
    Forum Contributor
    Join Date
    08-04-2010
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    143

    Re: coding for incrementing date by 1 month

    that is perfect. thank you very much Dom and have a nice day :D

    ps:what does "@" mean?

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: coding for incrementing date by 1 month

    It's just the code for formatting a cell as text.

    Dom

+ 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