![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 01:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com