View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Add years, months, days to a date

You could look at dateserial:

dim myDate as date

with activesheet.range("A1")
mydate = dateserial(year(.value)+2, month(.value)+3,day(.value)+4)
end with

msgbox mydate

wal wrote:

Excel 2003

With a worksheet function, you can add x years, y months, and z days
to a date using a formula like:

=DATE(YEAR(A1)+2, MONTH(A1)+3, DAY(A1)+4) [from Chip Pearson's site]

What is the analogous way of doing this in VBA? DATE is apparently
not a worksheet function available in VBA
(Application.WorksheetFunction). The DateAdd function in VBA lets you
add only one interval (years or months or days) at a time, and the
Help file examples don't go beyond this.

Thanks.


--

Dave Peterson