Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default 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
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
Create a List Output from a Horizontal Array Input Rob Excel Worksheet Functions 4 September 17th 09 05:40 PM
customise array formula output TUNGANA KURMA RAJU Excel Discussion (Misc queries) 0 October 25th 05 05:15 AM
Add value to array based on if...then output in VBA Scott P Excel Programming 4 June 14th 04 11:10 AM
Vertical Entries for VBA.Array cogent Excel Programming 3 April 22nd 04 03:52 AM
Help with 1 x 2 array output jomni[_3_] Excel Programming 3 April 2nd 04 03:49 PM


All times are GMT +1. The time now is 05:03 AM.

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

About Us

"It's about Microsoft Excel"