Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add month to date
I would like to add one month to a date in a cell overwriting it wit the new date. For example Cell A1 has the date 9/1/2004 and when m macro is run A1 becomes 10/1/2004. I can easily do this with the DATE(Year(a1),Month(a1)+1,day(a1) in cell but I need to run it from the macro and overwrite the existin cell. Any help is appreciated -- bugg ----------------------------------------------------------------------- buggy's Profile: http://www.excelforum.com/member.php...fo&userid=1666 View this thread: http://www.excelforum.com/showthread.php?threadid=31882 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add month to date
buggy,
Try this Sub ChangeDate() Dim Newdate Newdate = DateSerial(Year(Range("a1")), Month(Range("a1")) + 1, Day(Range("A1"))) ActiveSheet.Range("a1").Value = Newdate End Sub Neil "buggy" wrote in message ... I would like to add one month to a date in a cell overwriting it with the new date. For example Cell A1 has the date 9/1/2004 and when my macro is run A1 becomes 10/1/2004. I can easily do this with the DATE(Year(a1),Month(a1)+1,day(a1) in a cell but I need to run it from the macro and overwrite the existing cell. Any help is appreciated. -- buggy ------------------------------------------------------------------------ buggy's Profile: http://www.excelforum.com/member.php...o&userid=16666 View this thread: http://www.excelforum.com/showthread...hreadid=318823 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add month to date
Watch the line wrap for newdate Neil "Neil" wrote in message ... buggy, Try this Sub ChangeDate() Dim Newdate Newdate = DateSerial(Year(Range("a1")), Month(Range("a1")) + 1, Day(Range("A1"))) ActiveSheet.Range("a1").Value = Newdate End Sub Neil "buggy" wrote in message ... I would like to add one month to a date in a cell overwriting it with the new date. For example Cell A1 has the date 9/1/2004 and when my macro is run A1 becomes 10/1/2004. I can easily do this with the DATE(Year(a1),Month(a1)+1,day(a1) in a cell but I need to run it from the macro and overwrite the existing cell. Any help is appreciated. -- buggy ------------------------------------------------------------------------ buggy's Profile: http://www.excelforum.com/member.php...o&userid=16666 View this thread: http://www.excelforum.com/showthread...hreadid=318823 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add month to date
Hi
in VBA with activesheet.range("A1") ..value=dateserial(year(.value),month(.value)+1,da y(.value)) end with Note: this may give you wrong result for dates such as 31-Jan-2004 -- Regards Frank Kabel Frankfurt, Germany "buggy" schrieb im Newsbeitrag ... I would like to add one month to a date in a cell overwriting it with the new date. For example Cell A1 has the date 9/1/2004 and when my macro is run A1 becomes 10/1/2004. I can easily do this with the DATE(Year(a1),Month(a1)+1,day(a1) in a cell but I need to run it from the macro and overwrite the existing cell. Any help is appreciated. -- buggy --------------------------------------------------------------------- --- buggy's Profile: http://www.excelforum.com/member.php...o&userid=16666 View this thread: http://www.excelforum.com/showthread...hreadid=318823 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
count month when date is in day/month/year format | Excel Worksheet Functions | |||
Match Month in Date With Month in Header | Excel Worksheet Functions | |||
Date arithmetic: adding 1 month to prior end of month date | Excel Worksheet Functions | |||
Sort month/date/year data using month and date only | Excel Discussion (Misc queries) | |||
=VLOOKUP(1,Nationality!B5:B29,IF(MONTH(date)6,MONTH(date)-6, MON | Excel Worksheet Functions |