"Cannot Find" Using Analysis ToolPak Visual Basic FunctionLast reviewed: September 12, 1996Article ID: Q118797 |
The information in this article applies to:
SYMPTOMSIn 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.
CAUSEThis 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 WORKAROUNDSTo 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 STATUSMicrosoft 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.
MORE INFORMATIONTo view the Visual Basic functions that are included in the Analysis ToolPak-Visual Basic for Applications add-in, do the following:
|
KBCategory: kbtool kbfixlist
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |