View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Don Shepherd Don Shepherd is offline
external usenet poster
 
Posts: 2
Default simple function question

Hey, thanks Jim and Ron, your help is much appreciated. Yes, I noticed the
out of range subscript after I posted and fixed it, but the problem
persisted. The real culprit, as you suggested, was using integer data type
when I wanted a 10 digit integer result. I switched to double and it worked
like a charm.

Thanks again guys, you are a lifesaver!

"Don Shepherd" wrote in message
...
OK, I can't get this function to return anything other than #VALUE! What

am
I doing wrong? The function is in a module, and the input parameter is a
reference to a cell containing an integer.

Function my_digit_patt(a) As Integer
Dim ct(9) As Integer
For i = 1 To Len(a)
ct(Val(Mid(a, i, 1))) = ct(Val(Mid(a, i, 1))) + 1
Next
b = 0
For i = 0 To 10
b = b + ct(i) * 10 ^ (10 - i)
Next
my_digit_patt = b
End Function