mdmackillop
10-30-2004, 05:54 AM
Hi,
Can I declare an array in a similar fashion to a constant so that the data can be used by separate elements of a userform and sent to a function for processing. I don't want to put them on the Userform itself, if I can avoid it.
Something like the following
Cols = Array("A", "D", "G", "H")
Sub Test1()
'Cols = Array("A", "D", "G", "H")
Range(Cols(0) & "3").Select
End Sub
Sub test2()
Dim Cols()
'Cols = Array("A", "D", "G", "H")
For Each gc In GetCols(Cols)
msg = msg & gc & ", "
Next
MsgBox msg
End Sub
Function GetCols(Cols() As Variant) As Variant
Dim MyCols()
ReDim MyCols(UBound(Cols))
For i = 0 To UBound(Cols)
MyCols(i) = Range(Cols(i) & ":" & Cols(i)).Column()
Next
GetCols = MyCols
End Function
Can I declare an array in a similar fashion to a constant so that the data can be used by separate elements of a userform and sent to a function for processing. I don't want to put them on the Userform itself, if I can avoid it.
Something like the following
Cols = Array("A", "D", "G", "H")
Sub Test1()
'Cols = Array("A", "D", "G", "H")
Range(Cols(0) & "3").Select
End Sub
Sub test2()
Dim Cols()
'Cols = Array("A", "D", "G", "H")
For Each gc In GetCols(Cols)
msg = msg & gc & ", "
Next
MsgBox msg
End Sub
Function GetCols(Cols() As Variant) As Variant
Dim MyCols()
ReDim MyCols(UBound(Cols))
For i = 0 To UBound(Cols)
MyCols(i) = Range(Cols(i) & ":" & Cols(i)).Column()
Next
GetCols = MyCols
End Function