How can I build a Excel Function that acts like those built-in

W

wlh

I give column "A:A" a name as "Time",
so when I select column B and input an array formula as "=sin(Time)",for
different "Time" values I can get according
"Sin(time)" values.
I want to build a function MyFunc which is more complex than "Sin" ,below is
the code:
function MyFunc(t as variant) as double
select case typename(t)
case "Range"
MyFunc=MoreComplexFunc(t.Value)
'#Q1:How to get the proper Array item?
case else
MyFunc=MoreComplexFunc(Val(t))
end select
end function

what is the difficulty is that if I input formula "=MyFunc(Time)" in
different cells,the return values are the same.
Can somebody tell me how to pass/get the proper array item value?
 
B

Bill Manville

Wlh said:
Can somebody tell me how to pass/get the proper array item value?

case "Range"
If T.Cells.Count>1 Then
MyFunc =MoreComplexFunc(T.Cells(Application.Caller.Row - T.Row +
1, 1))
Else
MyFunc=MoreComplexFunc(t.Value)
End If



Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top