Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Is there a way to set the bounds explicitly using the 'To' and then do the assignment on one line something like Dim myArray( 1 to 20 ) as string myArray = {"one","two","Three"} ?? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Goofy" skrev i en meddelelse
... Hi, Is there a way to set the bounds explicitly using the 'To' and then do the assignment on one line something like Dim myArray( 1 to 20 ) as string myArray = {"one","two","Three"} ?? Hi If you have Excel 2000 or later, you can use the "Split" function: Sub test() Dim MyArray As Variant MyArray = "One,Two,Three" MyArray = Split(MyArray, ",") End Sub Split *always* return a zero-based array, even when you do an "Option Base 1"! -- Best regards Leo Heuser Followup to newsgroup only please. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
As you can see, Leo Heuser's code works on a Variant variable to change
it to a String() type array. And it changes it to, for the illustration you provided, a 3-element 0-based array (and it isn't clear why you Dimensioned the array at 1 to 20 in the first place when you were ending up with a smaller array). But in any event, if the functions in the freely downloadable file at http:??home.pacbell.net/beban are available to your workbook, you can work with what you described; this, too, will return a 3-element 0-based array. Sub abtest1() Dim arr() As String 'or As Integer, or whatever, so 'long as the assigned elements 'are of an acceptable type ReDim arr(1 To 20) assign Array(1, 2, 3), arr Debug.Print arr(0), UBound(arr), TypeName(arr) End Sub Alan Beban Leo Heuser wrote: "Goofy" skrev i en meddelelse ... Hi, Is there a way to set the bounds explicitly using the 'To' and then do the assignment on one line something like Dim myArray( 1 to 20 ) as string myArray = {"one","two","Three"} ?? Hi If you have Excel 2000 or later, you can use the "Split" function: Sub test() Dim MyArray As Variant MyArray = "One,Two,Three" MyArray = Split(MyArray, ",") End Sub Split *always* return a zero-based array, even when you do an "Option Base 1"! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Change from mixed caps and upper lower to all upper lower case | Excel Worksheet Functions | |||
Forms, Bound Columns etc | Excel Programming | |||
Data bound VBA forms | Excel Programming | |||
Cell Bound Combo Box | Excel Programming | |||
Listbox with Bound Columns | Excel Programming |