Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Changing Dates

I am looking to programmatically move a date forward or back by whole months
(i.e. 3, 6, or 9) - the sort of process carried out by Edate if used in a
formula. However, Edate doesn't seem to be available for use in VBA code.

Am I missing something or is there a different way around this.

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Changing Dates

Ian,
Look at VBA "DateAdd" function.

Code from VBA help ...


Dim FirstDate As Date ' Declare variables.
Dim IntervalType As String
Dim Number As Integer
Dim Msg
IntervalType = "m" ' "m" specifies months as interval.
FirstDate = InputBox("Enter a date")
Number = InputBox("Enter number of months to add")
Msg = "New date: " & DateAdd(IntervalType, Number, FirstDate)
MsgBox Msg

HTH

"IanC" wrote:

I am looking to programmatically move a date forward or back by whole months
(i.e. 3, 6, or 9) - the sort of process carried out by Edate if used in a
formula. However, Edate doesn't seem to be available for use in VBA code.

Am I missing something or is there a different way around this.

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Changing Dates

Ian,

Just set a reference to APTVBAEN.XLA in the VBIDE and you can then
programmatically use the ATP functions like

MsgBox Format(EDATE(Date, -3), "dd mmm yyyy")


--

HTH

RP
(remove nothere from the email address if mailing direct)


"IanC" wrote in message
...
I am looking to programmatically move a date forward or back by whole

months
(i.e. 3, 6, or 9) - the sort of process carried out by Edate if used in a
formula. However, Edate doesn't seem to be available for use in VBA code.

Am I missing something or is there a different way around this.

Thanks in advance.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Changing Dates

Spot on. Thank you very much.

"Toppers" wrote:

Ian,
Look at VBA "DateAdd" function.

Code from VBA help ...


Dim FirstDate As Date ' Declare variables.
Dim IntervalType As String
Dim Number As Integer
Dim Msg
IntervalType = "m" ' "m" specifies months as interval.
FirstDate = InputBox("Enter a date")
Number = InputBox("Enter number of months to add")
Msg = "New date: " & DateAdd(IntervalType, Number, FirstDate)
MsgBox Msg

HTH

"IanC" wrote:

I am looking to programmatically move a date forward or back by whole months
(i.e. 3, 6, or 9) - the sort of process carried out by Edate if used in a
formula. However, Edate doesn't seem to be available for use in VBA code.

Am I missing something or is there a different way around this.

Thanks in advance.

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
Dates changing E[_2_] Excel Discussion (Misc queries) 5 March 10th 09 03:21 PM
Stop UK-style dates changing to US-style dates when mailmerging. Jean XO Excel Discussion (Misc queries) 1 December 20th 07 12:35 PM
changing dates. chesty Excel Worksheet Functions 1 June 14th 06 03:04 PM
Changing Dates JohnG Excel Discussion (Misc queries) 1 May 17th 05 08:15 PM
Changing Dates JohnG Excel Discussion (Misc queries) 2 May 17th 05 06:22 PM


All times are GMT +1. The time now is 01:21 AM.

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"