ID: Q118797
In Microsoft Excel, if you use one of the functions provided in the Analysis ToolPak-Visual Basic for Applications add-in (ATPVBAEN.XLA), such as the EDATE() function, you receive the following error message:
Run-time error '1004':
Cannot find macro '[ATPVBAEN.XLA]REG!reg_EDATE'.
where the name of the function that you use appears in the place of
EDATE in the above error message.
This error message appears when you use any of the following Analysis ToolPak functions in a Visual Basic module:
New Function Old Function
----------------------------
EDATE NEWMONTH
EOMONTH NEWMONTHE
CUMIPMT CUMPI
TBILLEQ TBILLYEQ
TBILLPRICE TBILLP
TBILLYIELD TBILLY
To avoid receiving this error message when you use one of these functions in a Visual Basic procedure, you can do either of the following:
Sub Test()
Dim x as Date
x = Application.ExecuteExcel4Macro("EDATE(datevalue(""1/1/94""),5)")
End Sub
NOTE: When you use this method with the EOMONTH() function, the value
returned is one day less than the correct value. To avoid this
problem, use the workaround below.
-or-
' This function returns the serial number date for the last day of the
' month that is the indicated number of months before or after
' start_date.
Function EO_Month(start_date, months)
EO_Month = DateSerial(Year(start_date), _
Month(start_date) + months + 1, 0)
End Function
'This function returns the serial number date that is the indicated
'number of months before or after start_date.
Function E_Date(start_date, months)
Dim DaysInMonth As Integer
DaysInMonth = Day(DateSerial(Year(start_date), _
Month(start_date) + months + 1, 1) - 1)
If Day(start_date) > DaysInMonth Then
E_Date = DateSerial(Year(start_date), _
Month(start_date) + months, DaysInMonth)
Else
E_Date = DateSerial(Year(start_date), _
Month(start_date) + months, Day(start_date))
End If
End Function
' Example procedure using EO_Month function
Sub Test1()
Dim x As Date
x = EO_Month(start_date:="1/1/94", months:="5")
MsgBox x
End Sub
' Example procedure using E_Date function
Sub Test2()
Dim x as Date
x = E_Date(start_date:="1/1/94", months:="5")
MsgBox x
End Sub
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel for Windows version 5.0c.
Note that in Microsoft Excel version 5.0c, you only receive this error message when you use a function in ATPVBAEN.XLA if the file is not open when you run the procedure that contains the function.
To view the Visual Basic functions that are included in the Analysis ToolPak-Visual Basic for Applications add-in, do the following:
1. Open the file ATPVBAEN.XLA (located in the LIBRARY\ANALYSIS
subdirectory of the Microsoft Excel directory).
2. In a Visual Basic module, choose Object Browser from the View menu.
3. From the Libraries/Workbooks list, select ATPVBAEN.XLA.
The Methods/Properties list contains all of the Visual Basic functions included in the Analysis ToolPak - Visual Basic for Applications add-in.
Additional query words: 5.00 atp addins err msg
Keywords : xlwin kbfixlist
Version : 5.00
Platform : WINDOWS
Last Reviewed: June 1, 1999