Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to pass a dynamic array FROM a function TO a sub

Hi all, I'm having a lot of trouble trying to figure this one out...

I have 1 workbook with 2 sheets
worksheet 1 has data in columns A and B (let's say 10 rows, but the
number can vary)
Using a function, I want to read that information into an array, and
pass that array to SUB xyz()
sub xyz() will then select my second sheet, and paste the array in
column C and D

Try as I might, I can't get it to work; it fails on Ubound(positions).
Holding my mouse pointer over Ubound(positions), I get a "subscript
out of range" error. Can someone please tell me what I'm doing wrong?
Thanks in advance,

Al


Sub xyz()
Dim Positions()
Call copyover
sheets("2").select

For i = 1 To UBound(positions)
Range("C" & i) = positions(1, i)
Range("D" & i) = positions(1, i)
Next i

End Sub

---------------------------------------------------------

Function copyover(positions) As Variant()
pfrow = 1
Dim holdings()

Range("A1").Select

While Range("A" & pfrow).Value < ""
ReDim Preserve holdings(2, pfrow)
holdings(1, pfrow) = Range("A" & pfrow)
holdings(2, pfrow) = Range("B" & pfrow)
pfrow = pfrow + 1
Wend
positions = holdings

End Function
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
Pass an array Karen53 Excel Programming 5 November 28th 07 02:17 AM
How to pass arguments to an Excel macro using Dynamic Data Exchang Ted Excel Programming 2 June 28th 07 06:04 PM
Dynamic multiple-condition array function with more than one name Gary F Excel Worksheet Functions 3 September 15th 06 03:24 PM
combining cells and array from different sheets into an array to pass to IRR() [email protected] Excel Discussion (Misc queries) 3 September 11th 06 07:17 AM
Pass an array to Rank Biff Excel Worksheet Functions 12 June 29th 05 04:15 PM


All times are GMT +1. The time now is 10:02 PM.

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"