Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
UDF, Array function, vertical output
This is probably a simple answer. I have a UDF that retrieves stock prices
from a database. The return values should obviously be laid out vertically. The UDF is returning the correct values when entered horizontally, but will only give the correct answers when I use Transpose(UDF) in a vertical format. Am I missing something here? Is there a way to get an array based UDF to work with vertical output without having to use the transpose function? Thanks, Robin Hammond www.enhanceddatasystems.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
UDF, Array function, vertical output
You can do the transpose inside the VBA, i.e.
Function GetPrices() As Variant Dim V as Variant 'code here to load V with your array of prices here GetPrices = Application.Transpose(V) End Function Or, depending on how the prices are returned from the database, you could Dim and fill your own array: Function GetPrices() As Double() Dim i As Long Dim Prices() As Double ReDim Prices(1 To 3, 1 To 1) For i = 1 To 3 Prices(i, 1) = Round(Rnd() * 50, 3) Next i GetPrices = Prices() End Function On Thu, 30 Sep 2004 11:23:30 +0800, "Robin Hammond" wrote: This is probably a simple answer. I have a UDF that retrieves stock prices from a database. The return values should obviously be laid out vertically. The UDF is returning the correct values when entered horizontally, but will only give the correct answers when I use Transpose(UDF) in a vertical format. Am I missing something here? Is there a way to get an array based UDF to work with vertical output without having to use the transpose function? Thanks, Robin Hammond www.enhanceddatasystems.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
UDF, Array function, vertical output
Myrna,
Just what I needed. Many thanks. Robin Hammond www.enhanceddatasystems.com "Myrna Larson" wrote in message ... You can do the transpose inside the VBA, i.e. Function GetPrices() As Variant Dim V as Variant 'code here to load V with your array of prices here GetPrices = Application.Transpose(V) End Function Or, depending on how the prices are returned from the database, you could Dim and fill your own array: Function GetPrices() As Double() Dim i As Long Dim Prices() As Double ReDim Prices(1 To 3, 1 To 1) For i = 1 To 3 Prices(i, 1) = Round(Rnd() * 50, 3) Next i GetPrices = Prices() End Function On Thu, 30 Sep 2004 11:23:30 +0800, "Robin Hammond" wrote: This is probably a simple answer. I have a UDF that retrieves stock prices from a database. The return values should obviously be laid out vertically. The UDF is returning the correct values when entered horizontally, but will only give the correct answers when I use Transpose(UDF) in a vertical format. Am I missing something here? Is there a way to get an array based UDF to work with vertical output without having to use the transpose function? Thanks, Robin Hammond www.enhanceddatasystems.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Create a List Output from a Horizontal Array Input | Excel Worksheet Functions | |||
customise array formula output | Excel Discussion (Misc queries) | |||
Add value to array based on if...then output in VBA | Excel Programming | |||
Vertical Entries for VBA.Array | Excel Programming | |||
Help with 1 x 2 array output | Excel Programming |