Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
count month when date is in day/month/year format ccKennedy Excel Worksheet Functions 6 April 30th 09 03:32 AM
Match Month in Date With Month in Header [email protected] Excel Worksheet Functions 1 August 17th 07 07:46 PM
Date arithmetic: adding 1 month to prior end of month date manxman Excel Worksheet Functions 2 July 14th 06 09:29 PM
Sort month/date/year data using month and date only SMW820 Excel Discussion (Misc queries) 6 June 22nd 06 05:14 PM
=VLOOKUP(1,Nationality!B5:B29,IF(MONTH(date)6,MONTH(date)-6, MON Ali Excel Worksheet Functions 14 January 18th 06 08:20 AM


All times are GMT +1. The time now is 01:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"