Hi,
I can not find how to put the strings i have in a range (a1:a10) into an array of string that I can user later on with a loop.
PD: The range may have 10, 5 or 200 strings (cells) and the array (Sub) should recognize the number of items.
Thanks.
A1: John
a2: Mary
etc..
How can I do this dynamically:
Public Sub SingleDimension()
' Define a variant to hold individual strings.
Dim IndividualString As Variant
' Define the array of strings.
Dim StringArray(5) As String
' Fill each array element with information.
StringArray(0) = "This"
StringArray(1) = "Is"
StringArray(2) = "An"
StringArray(3) = "Array"
StringArray(4) = "Of"
StringArray(5) = "Strings"
' Use the For Each...Next statement to get each array
' element and place it in a string.
For Each IndividualString In StringArray
' Create a single output string with the array
' array elements.
Output = Output + IndividualString + " "
Next
' Display the result.
MsgBox Trim(Output), _
vbInformation Or vbOKOnly, _
"Array Content"
End Sub
Thanks
I can not find how to put the strings i have in a range (a1:a10) into an array of string that I can user later on with a loop.
PD: The range may have 10, 5 or 200 strings (cells) and the array (Sub) should recognize the number of items.
Thanks.
A1: John
a2: Mary
etc..
How can I do this dynamically:
Public Sub SingleDimension()
' Define a variant to hold individual strings.
Dim IndividualString As Variant
' Define the array of strings.
Dim StringArray(5) As String
' Fill each array element with information.
StringArray(0) = "This"
StringArray(1) = "Is"
StringArray(2) = "An"
StringArray(3) = "Array"
StringArray(4) = "Of"
StringArray(5) = "Strings"
' Use the For Each...Next statement to get each array
' element and place it in a string.
For Each IndividualString In StringArray
' Create a single output string with the array
' array elements.
Output = Output + IndividualString + " "
Next
' Display the result.
MsgBox Trim(Output), _
vbInformation Or vbOKOnly, _
"Array Content"
End Sub
Thanks