View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default #NAME? error in function

Why are you trying to use a Sum function on what looks like straight
addition? What will the variables Usage and LeadTime contain... individual
numbers or an array of values? Because your function is trying to use Sum on
Usage/12*LeadTime, but not Usage/12*SafetyStock, I can only conclude Usage
is a single value and LeadTime just doesn't seem to be an array in this
situation... so I would think an attempt to use Sum could be eliminated
altogether. As Dave mentioned in his post, VBA doesn't actually have a Sum
or RoundUp function, so you can call out to the worksheet functions to
duplicate them. However, if I am right that none of the arguments in your
function call will be arrays, and that Sum isn't really needed, then you can
use a simple modification to VB's Round function to create RoundUp
functionality...

Function ROP(Usage, LeadTime, SafetyStock)
Value = (Usage / 12 * LeadTime) + (Usage / 12 * SafetyStock)
ROP = Round(Value - (CLng(Value) < Value))
End Function

--
Rick (MVP - Excel)


"Michael Smith" wrote in message
...
Hi all, I'm creating my first function, and I think I have it right, but
excel doesn't recognize my function and returns #NAME? Is there a
problem with my code?,.. or is this a referencing problem in VBE. I am
saving this in a module in personal.xlsx
Thanks!
-Mike

Function ROP(Usage, LeadTime, SafetyStock)
ROP = RoundUp(Sum(Usage / 12 * LeadTime) + (Usage / 12 *
SafetyStock), 0)
End Function

*** Sent via Developersdex http://www.developersdex.com ***