Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Passing an array as argument for custom Function

I am trying to find out how to pass an array as an
argument for a custom function.
I have an array colors(1 to 10) and I want to pass the
whole array into a custom fundtion so I can use the array
within the function.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Passing an array as argument for custom Function

Use the ParamArray keyword
Function zzz(ParamArray myarr())

" wrote:

I am trying to find out how to pass an array as an
argument for a custom function.
I have an array colors(1 to 10) and I want to pass the
whole array into a custom fundtion so I can use the array
within the function.

Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Passing an array as argument for custom Function

And how do I enter the argument when I use the function.
Can I just do:

zzz(colors())

-----Original Message-----
Use the ParamArray keyword
Function zzz(ParamArray myarr())

" wrote:

I am trying to find out how to pass an array as an
argument for a custom function.
I have an array colors(1 to 10) and I want to pass the
whole array into a custom fundtion so I can use the

array
within the function.

Thanks.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Passing an array as argument for custom Function

I'm pretty sure you would just pass the name: zzz(colors)

" wrote:

And how do I enter the argument when I use the function.
Can I just do:

zzz(colors())

-----Original Message-----
Use the ParamArray keyword
Function zzz(ParamArray myarr())

" wrote:

I am trying to find out how to pass an array as an
argument for a custom function.
I have an array colors(1 to 10) and I want to pass the
whole array into a custom fundtion so I can use the

array
within the function.

Thanks.

.


  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Passing an array as argument for custom Function

When I do that, it seems to only pass the first item in
the array.
For example, lets say I have the following function and
procedu

Sub test()
Dim colors(1 To 10) As Integer

For i = 1 To 10
colors(i) = i + 10
Next i
zzz(colors)
End Sub

Function zzz(ParamArray myarr() As Variant)
Range("B1") = myarr(1)
End Function

When I use myarr(0) in the zzz function, it works fine,
but when I try to use myarr(1), I get a "Subscript out of
range" message.

-----Original Message-----
I'm pretty sure you would just pass the name: zzz(colors)

" wrote:

And how do I enter the argument when I use the function.
Can I just do:

zzz(colors())

-----Original Message-----
Use the ParamArray keyword
Function zzz(ParamArray myarr())

" wrote:

I am trying to find out how to pass an array as an
argument for a custom function.
I have an array colors(1 to 10) and I want to pass

the
whole array into a custom fundtion so I can use the

array
within the function.

Thanks.

.


.

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
Need help passing an array as an argument blc[_3_] Excel Programming 3 August 4th 04 10:35 PM
Passing range as an argument in a function Hari[_3_] Excel Programming 1 June 15th 04 02:41 AM
VBA - Passing a FUNCTION as an Argument James B Excel Programming 3 February 18th 04 03:42 PM
Passing an Array of User-Defined Type to an Argument of a Function Tushar Mehta[_6_] Excel Programming 0 August 17th 03 06:43 PM
passing a variable as an argument to a function Drew[_6_] Excel Programming 3 July 25th 03 08:51 PM


All times are GMT +1. The time now is 04:41 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"