> ...Split..Is there a straight-forward to cause the first index to be
> one?
Hi. Here's a common workaround that I use:
Sub Demo()
Dim s, v
s = "a,b,c,d,e"
v = Split(s, ",")
v = T2(v)
End Sub
Function T2(v)
'// Double Transpose
With WorksheetFunction
T2 = .Transpose(.Transpose(v))
End With
End Function
= = = = = = = = = = =
HTH :>)
Dana DeLouis
On 12/23/2009 8:19 PM, Joe User wrote:
> "Rick Rothstein" <(E-Mail Removed)> wrote:
>> Well, let my take back the "No" part of my response...
>> you can "fake it" if you want...
> [....]
>> w = Split(" " & mylist)
>
> Well, duh! I must be getting old :-).
>
>
> ----- original message -----
>
> "Rick Rothstein" <(E-Mail Removed)> wrote in message
> news:e7X7$(E-Mail Removed)...
>> Well, let my take back the "No" part of my response... you can "fake
>> it" if you want... just add the delimiter to the front of the text
>> being split... you will still get a zero-based array, but the zero
>> element will be the empty string and the first real element will be at
>> index value 1. So, just change your statement to this...
>>
>> w = Split(" " & mylist)
>>
>> where I used a space because Split uses a space as the delimiter by
>> default when no delimiter is specified. If you were were working with
>> a comma delimited list, then your statement would be this...
>>
>> w = Split("," & mylist, ",")
>>
>> --
>> Rick (MVP - Excel)
>>
>>
>> "Rick Rothstein" <(E-Mail Removed)> wrote in
>> message news:%(E-Mail Removed)...
>>> No, Split is unusual in that it **always** returns a zero-based array
>>> even if you use "Option Base 1" to force the lower bound of arrays to
>>> be one.
>>>
>>> --
>>> Rick (MVP - Excel)
>>>
>>>
>>> "Joe User" <joeu2004> wrote in message
>>> news:(E-Mail Removed)...
>>>> Currently, I use Split as follows:
>>>>
>>>> Dim w, mylist as string
>>>> w = Split(mylist)
>>>>
>>>> That creates an array with the first index (LBound) of zero.
>>>>
>>>> Is there a straight-forward to cause the first index to be one?
>>>>
>>>> (I don't know the number of "words" in mylist a priori.)
>>>>
>>>> I am using Excel 2003 SP3 with VBA 6.5.1024.
>>>
>>
>
|