Computing a minimum in a user-defined function
Pardon me if I use the wrong words -- I'm a software guy, not a spreadsheet
guy. I am trying to write a function (macro?). Unfortunately, the function is choking on Min(a,b). Here's an example: (I invoke this by typing "=myfunc(+B12)" in a cell) function myfunc(a as currency) as currency Dim Result As Currency Dim x As Currency Result = 0 x = Min(100000, a) <== doesn't like this at run-time Result = Result + x * 0.07 .... end function |
Computing a minimum in a user-defined function
I think you want something like this:
Function myfunc(a As Currency) As Currency myfunc = WorksheetFunction.Min(100000, a) * 0.07 End Function RBS "JeremyGrand" wrote in message ... Pardon me if I use the wrong words -- I'm a software guy, not a spreadsheet guy. I am trying to write a function (macro?). Unfortunately, the function is choking on Min(a,b). Here's an example: (I invoke this by typing "=myfunc(+B12)" in a cell) function myfunc(a as currency) as currency Dim Result As Currency Dim x As Currency Result = 0 x = Min(100000, a) <== doesn't like this at run-time Result = Result + x * 0.07 ... end function |
All times are GMT +1. The time now is 04:51 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com