View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
mala mala is offline
external usenet poster
 
Posts: 3
Default Problem with UDF

I am getting the data in the form of 2/5, 10/18, 5/8 etc.
I need to sum the figures to the left of "/" (slash)and right of "/"
(slash)
To acheive this I am creating two UDF for left and right each.
So far I have this :

Function slsum(kk) As Range
Dim mysum
mysum = 0
For Each cell In kk
'=+LEFT(A2,FIND("/",A2)-1) ----This formula works when entered in cell
pp = WorksheetFunction.Sum(Left(kk, WorksheetFunction.Find("/", kk) -
1))'*ERROR LINE*
mysum = mysum + pp
Next
slsum = mysum
End Function

The error line marked above gives me error of type mismatch.
If I give range as single cell, last line slsum=mysum gives error of
"Object variable or with block variable not set"

Request for solution please.
Regards,
Manakmala.