PDA

View Full Version : Solved: How many substrings returned by Split() ?



RonMcK
03-26-2011, 06:40 PM
Hi, All,

Is that an easy way to determine how many elements are in the Array returned when I use Split() ?

Or do I need to resort to something like this?
i = 0
On Error GoTo Next_step
Do While myArray(i) <> ""
i = i + 1
Loop
Next_step:
On Error GoTo 0


Thanks,

Kenneth Hobs
03-26-2011, 07:58 PM
Use lbound() and ubound() to find the lower and upper boundary limits. Of course Split() makes the lbound() to be 0 by design.

Bob Phillips
03-27-2011, 02:17 AM
You can also use this



Dim myArray As Variant
Dim aryItem As Variant


myArray = Split("1,2,3,4,5,6", ",")
For Each aryItem In myArray
Debug.Print aryItem
Next aryItem

RonMcK
03-27-2011, 01:43 PM
Bob and Kenneth,

Thank you very much for your answers. They both help expand my knowledge of this wee beasty, XL.

Thanks,