dcx693
Registered User.
- Local time
- Today, 06:51
- Joined
- Apr 30, 2003
- Messages
- 3,265
Call an Excel function from Access
As long as you've got Access and Excel on the same machine, you can make a simple automation call to Excel and use Excel's built-in functions. Here's a simple example using the Excel Small function:
This function sends Excel an array of numbers and asks it to locate the nth smallest one in the array. Just call the function from Access like:
Just be aware that each time you call the function, that you're making a separate automation call to Excel. You'll have to test it in your specific case to see if the speed is acceptable.
As long as you've got Access and Excel on the same machine, you can make a simple automation call to Excel and use Excel's built-in functions. Here's a simple example using the Excel Small function:
Code:
Function GetNthNumber(intPosition As Integer, _
ParamArray dblNums() As Variant) As Double
Dim obj As Object
Set obj = CreateObject("Excel.Application")
GetNthNumber = obj.Small(Array(dblNums()), intPosition)
obj.Quit
Set obj = Nothing
End Function
Code:
dblAnswer=GetNthNumber(2,1,2,4,2,5,7)