Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default An alternative for the edate function...

Is there a good alternative for the edate function?

Don't want to use it in vba - due to the tool analysis toolpack. Not
everyone has it installed.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default An alternative for the edate function...

On 24 Okt., 10:41, TFriis wrote:
Is there a good alternative for the edate function?

Don't want to use it in vba - due to the tool analysis toolpack. Not
everyone has it installed.


Never mind - found a solution :]

Sub AlternativeEdateFunction()

Dim start_date As Date
Dim No_Months As Integer

start_date = VBA.Date
No_Months = 3

Range("A1") = VBA.DateSerial(VBA.Year(start_date),
VBA.Month(start_date) + No_Months,
Application.WorksheetFunction.Min(VBA.Day(start_da te),
VBA.Day(VBA.DateSerial(VBA.Year(start_date), VBA.Month(start_date) +
No_Months + 1, 0))))

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default An alternative for the edate function...

Hi,

It's not clear from your post what you want.
Edate formula
=EDATE(A1,1)

VB equivalent
mydate = DateAdd("m", 1, Range("a1").Value)

On the worksheet without ATP
=DATE(YEAR(A1),MONTH(A1)+1,DAY(A1))

Mike

"TFriis" wrote:

Is there a good alternative for the edate function?

Don't want to use it in vba - due to the tool analysis toolpack. Not
everyone has it installed.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default An alternative for the edate function...

On 24 Okt., 11:01, Mike H wrote:
Hi,

It's not clear from your post what you want.
Edate formula
=EDATE(A1,1)

VB equivalent
mydate = DateAdd("m", 1, Range("a1").Value)

On the worksheet without ATP
=DATE(YEAR(A1),MONTH(A1)+1,DAY(A1))

Mike

"TFriis" wrote:
Is there a good alternative for the edate function?


Don't want to use it in vba - due to the tool analysis toolpack. Not
everyone has it installed.



Your worksheet formula doesn't work; try the date 31/01/2008 ("dd/mm/
yyyy") (It returns 02/03/2008 ("dd/mm/yyyy") - where 29/02/2008 ("dd/
mm/yyyy") is the correct date.

I do believe

=MIN(DATE(YEAR(Range("a1").Value),MONTH(Range("a1" ).Value)
+1,DAYRange("a1").Value)),
DATE(YEAR(Range("a1").Value),MONTH(Range("a1").Val ue)+1+1,0))

works as a charm. I made that one in VBA - not realizing I could have
use DateAdd :)
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default An alternative for the edate function...

How about these instead...

It's not clear from your post what you want.
Edate formula
=EDATE(A1,1)


VB equivalent


D = DateSerial(Year(Range("A1").Value), Month(Range("A1").Value) + 2, 0)

On the worksheet without ATP


=DATE(YEAR(A1),MONTH(A1)+2,0)

--
Rick (MVP - Excel)


"TFriis" wrote in message
...
On 24 Okt., 11:01, Mike H wrote:
Hi,

It's not clear from your post what you want.
Edate formula
=EDATE(A1,1)

VB equivalent
mydate = DateAdd("m", 1, Range("a1").Value)

On the worksheet without ATP
=DATE(YEAR(A1),MONTH(A1)+1,DAY(A1))

Mike

"TFriis" wrote:
Is there a good alternative for the edate function?


Don't want to use it in vba - due to the tool analysis toolpack. Not
everyone has it installed.



Your worksheet formula doesn't work; try the date 31/01/2008 ("dd/mm/
yyyy") (It returns 02/03/2008 ("dd/mm/yyyy") - where 29/02/2008 ("dd/
mm/yyyy") is the correct date.

I do believe

=MIN(DATE(YEAR(Range("a1").Value),MONTH(Range("a1" ).Value)
+1,DAYRange("a1").Value)),
DATE(YEAR(Range("a1").Value),MONTH(Range("a1").Val ue)+1+1,0))

works as a charm. I made that one in VBA - not realizing I could have
use DateAdd :)


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
EDATE Function JAD Excel Worksheet Functions 4 October 24th 08 05:55 PM
Array Function & EDATE Harimau Excel Worksheet Functions 3 April 14th 08 12:14 PM
edate function I Cruz Excel Worksheet Functions 1 April 4th 06 08:45 PM
edate function Candace Excel Worksheet Functions 2 November 2nd 05 09:07 PM
edate function in VBA fdiez67 Excel Programming 3 November 18th 03 08:13 PM


All times are GMT +1. The time now is 04:22 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"