LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Excel2000: UDF's parameter as cell range OR array

Hi Arvi

For data in vectors, something along these lines:

Function Test(Var As Variant) As Variant
'Leo Heuser, 19-4-2005
Dim Counter As Long
Dim Dummy As Long
Dim ResultValue As Variant
Dim Sm As Double
Dim Trans As Boolean

If TypeName(Var) = "Range" Then
ResultValue = Var.Value
If UBound(ResultValue, 2) 1 Then Trans = True
Else
ResultValue = Var
On Error Resume Next
Dummy = UBound(ResultValue, 2)
If Err.Number 0 Then Trans = True
On Error GoTo 0
End If

If Trans Then ResultValue = _
Application.Transpose(ResultValue)

For Counter = 1 To UBound(ResultValue)
Sm = Sm + ResultValue(Counter, 1)
Next Counter

Test = Sm

End Function

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"Arvi Laanemets" skrev i en meddelelse
...
Hi

How to create an UDF which can have as parameter either the cell range or
an
array, i.e both syntaxes in examples below will work:

=MyFunction(A2,B2,OtherSheet!$A$2:$A$7)
or
=MyFunction(A2,B2,{2;3;4;5;6;7})


Thanks in advance
--
When sending mail, use address arvil<attarkon.ee
Arvi Laanemets






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel2000:How to link Print Area with a named range Arvi Laanemets Excel Worksheet Functions 5 April 8th 08 02:35 PM
Defining new function with cell range parameter NormD Excel Programming 2 March 1st 05 03:21 PM
Printing date range in excel2000 No Name Excel Programming 1 November 18th 04 02:13 PM
Excel2000: Reading Named Range value from VBA Arvi Laanemets Excel Programming 2 July 9th 04 09:01 AM
Excel2000: finding last row of used range Arvi Laanemets Excel Programming 2 May 10th 04 08:54 AM


All times are GMT +1. The time now is 11:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"