I am trying to write a DLL and have its functions accessible to Excel so that the code runs faster (right now, I have one module taking about 2 minutes to calculate). I wrote the following code in Visual Basic 6.0 Pro:
Public Function TimesFive(x As Double) As Double
TimesFive = x * 5
End Function
And compiled to a .dll called X5.dll
I wrote this bit of code into Excel 2000 to try to call it:
Declare Function TimesFive Lib "C:\X5.dll" _
(x As Double) As Double
Function CallX5(a As Double) As Double
CallX5 = TimesFive(a)
End Function
I also made a reference to the .DLL in the vba module. In the spreadsheet, I typed "1" into A1, and "=CallX5(A1)" into A2. But I get the #VALUE! error. Anyone have any ideas? I have tried inserting ByVal into all argument declarations, accessing the .DLL function directly from the spreadsheet, etc, but to no avail.
Public Function TimesFive(x As Double) As Double
TimesFive = x * 5
End Function
And compiled to a .dll called X5.dll
I wrote this bit of code into Excel 2000 to try to call it:
Declare Function TimesFive Lib "C:\X5.dll" _
(x As Double) As Double
Function CallX5(a As Double) As Double
CallX5 = TimesFive(a)
End Function
I also made a reference to the .DLL in the vba module. In the spreadsheet, I typed "1" into A1, and "=CallX5(A1)" into A2. But I get the #VALUE! error. Anyone have any ideas? I have tried inserting ByVal into all argument declarations, accessing the .DLL function directly from the spreadsheet, etc, but to no avail.