Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Dates changing | Excel Discussion (Misc queries) | |||
Stop UK-style dates changing to US-style dates when mailmerging. | Excel Discussion (Misc queries) | |||
changing dates. | Excel Worksheet Functions | |||
Changing Dates | Excel Discussion (Misc queries) | |||
Changing Dates | Excel Discussion (Misc queries) |