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


Reply With Quote

If that were the method, as I sometimes find myself lacking options, you can add different qualifying lines to your code so you don't have to keep writing multiple Public Functions. You can just call from the sub routine and assign them in your Function ...