PC Review


Reply
 
 
Imda14u
Guest
Posts: n/a
 
      12th Jul 2009
Hi all,

some worksheetfunctions need to be confirmed as Array function with Ctrl
+ Shift + Enter. Same thing for formulaconstructions where you have only
one fomrula for a range.

Can you also write your own UDF as array function?

Any idea where I can find a reference?

greets,

Sybolt
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      12th Jul 2009
Here is an example

Function myFunction(inDate As Date, inType As String) As Variant
Dim nextDate As Date
Dim i As Long
Dim cCells As Long
Dim tmpArray() As Date

nextDate = inDate
cCells = application.caller.Cells.Count
ReDim Preserve tmpArray(0 To cCells)
For i = 1 To cCells
tmpArray(i - 1) = nextDate
Select Case LCase(inType)
Case "day": nextDate = nextDate + 1
Case "week": nextDate = nextDate + 7
Case "month": nextDate = nextDate + 30
Case "year": nextDate = nextDate + 365
End Select
Next i

If Application.Caller.Rows.Count = 1 Then
myFunction = tmpArray
Else
myFunction = Application.Transpose(tmpArray)
End If

End Function

You would select the target range, and array enter
=MyFunction(TODAY(),"week") as an example.

--
__________________________________
HTH

Bob

"Imda14u" <(E-Mail Removed)> wrote in message
news:4a599ed3$0$191$(E-Mail Removed)...
> Hi all,
>
> some worksheetfunctions need to be confirmed as Array function with Ctrl +
> Shift + Enter. Same thing for formulaconstructions where you have only one
> fomrula for a range.
>
> Can you also write your own UDF as array function?
>
> Any idea where I can find a reference?
>
> greets,
>
> Sybolt



 
Reply With Quote
 
Doug Jenkins
Guest
Posts: n/a
 
      13th Jul 2009
In short, you can make a UDF an array function by declaring it as a Variant,
and assigning the function return value to an array:

Function FunctionName(..) as variant
...
FunctionName = ArrayName
End Function




"Imda14u" wrote:

> Hi all,
>
> some worksheetfunctions need to be confirmed as Array function with Ctrl
> + Shift + Enter. Same thing for formulaconstructions where you have only
> one fomrula for a range.
>
> Can you also write your own UDF as array function?
>
> Any idea where I can find a reference?
>
> greets,
>
> Sybolt
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent cell/array references from changing when altering/moving thecell/array nme Microsoft Excel Misc 1 19th Sep 2008 01:53 PM
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R Microsoft Excel Programming 3 13th Nov 2007 04:08 PM
meaning of : IF(Switch; Average(array A, array B); array A) =?Utf-8?B?RFhBVA==?= Microsoft Excel Worksheet Functions 1 24th Oct 2006 06:11 PM
Pass from C# (framework 1.1) array of delegates to unmanaged DLL as array of function pointers verpeter@gmail.com Microsoft C# .NET 0 23rd Aug 2006 02:20 PM
select variables ranges, copy to array, paste the array in new workbook Mathew Microsoft Excel Worksheet Functions 1 1st Apr 2005 09:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:39 PM.