Changing Dates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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)
 
Spot on. Thank you very much.

Toppers said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top