ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   using array as argument in VBA sub (https://www.excelbanter.com/excel-programming/377258-using-array-argument-vba-sub.html)

DRA

using array as argument in VBA sub
 
I am trying to pass an array to a subroutine. I always get an error.

in calling code:
MMBkList = Array("Add to Not Budgeted", "Add to Charity", "Add to
Cash")
Call mylistbox("Add to which Column?", MMBkList, col)
..
..
..

Sub MyListBox(Cptn As String, ByRef List() As Variant, Item)

Help?

Thanks,
DRA

Jim Cone

using array as argument in VBA sub
 
Changing List() to List will work, however, it would be better to use
another variable name; maybe vList.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"DRA"
wrote in message
I am trying to pass an array to a subroutine. I always get an error.

in calling code:
MMBkList = Array("Add to Not Budgeted", "Add to Charity", "Add to Cash")
Call mylistbox("Add to which Column?", MMBkList, col)

Sub MyListBox(Cptn As String, ByRef List() As Variant, Item)

Help?
Thanks,
DRA

Bob Phillips

using array as argument in VBA sub
 
Sub MyListBox(Cptn As String, ByRef List, Item)


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"DRA" wrote in message
...
I am trying to pass an array to a subroutine. I always get an error.

in calling code:
MMBkList = Array("Add to Not Budgeted", "Add to Charity", "Add to
Cash")
Call mylistbox("Add to which Column?", MMBkList, col)
.
.
.

Sub MyListBox(Cptn As String, ByRef List() As Variant, Item)

Help?

Thanks,
DRA




[email protected]

using array as argument in VBA sub
 
Try removing the () after List, ie:

Sub MyListBox(Cptn As String, ByRef List() As Variant, Item)

A variant can hold an array by itself. You do not need an array of
Variants.

Regards,
Steve

DRA wrote:
I am trying to pass an array to a subroutine. I always get an error.

in calling code:
MMBkList = Array("Add to Not Budgeted", "Add to Charity", "Add to
Cash")
Call mylistbox("Add to which Column?", MMBkList, col)
.
.
.

Sub MyListBox(Cptn As String, ByRef List() As Variant, Item)

Help?

Thanks,
DRA



DRA

using array as argument in VBA sub
 
Thanks to all of!

DRA

" wrote:

Try removing the () after List, ie:

Sub MyListBox(Cptn As String, ByRef List() As Variant, Item)

A variant can hold an array by itself. You do not need an array of
Variants.

Regards,
Steve

DRA wrote:
I am trying to pass an array to a subroutine. I always get an error.

in calling code:
MMBkList = Array("Add to Not Budgeted", "Add to Charity", "Add to
Cash")
Call mylistbox("Add to which Column?", MMBkList, col)
.
.
.

Sub MyListBox(Cptn As String, ByRef List() As Variant, Item)

Help?

Thanks,
DRA




Tom Ogilvy

using array as argument in VBA sub
 
Or do it this way in Excel 2000 or later:

Sub AAA()
Dim MMBkList() As Variant
MMBkList = Array("Add to Not Budgeted", "Add to Charity", "Add to Cash ")
Call MyListBox("Add to which Column?", MMBkList, col)
End Sub

Sub MyListBox(Cptn As String, ByRef List() As Variant, Item)

End Sub

--
Regards,
Tom Ogilvy

"DRA" wrote in message
...
Thanks to all of!

DRA

" wrote:

Try removing the () after List, ie:

Sub MyListBox(Cptn As String, ByRef List() As Variant, Item)

A variant can hold an array by itself. You do not need an array of
Variants.

Regards,
Steve

DRA wrote:
I am trying to pass an array to a subroutine. I always get an error.

in calling code:
MMBkList = Array("Add to Not Budgeted", "Add to Charity", "Add
to
Cash")
Call mylistbox("Add to which Column?", MMBkList, col)
.
.
.

Sub MyListBox(Cptn As String, ByRef List() As Variant, Item)

Help?

Thanks,
DRA







All times are GMT +1. The time now is 05:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com