loop through array?
New to vba and need help. Looping through an array. The array is the value from a text box where a user enters numbers and each number is on a new line. How can I get the value of this into an array and print each value? So far I have the below and all I get is one message box with all the data from the form message box.
Private Sub CommandButton1_Click()
Dim myArray As Variant
Dim x As Integer
Dim val As Variant
Dim strString As Variant
If TextBox1.Value = "" Then
MsgBox "There is no data in text box. Cannot build Macro!"
Exit Sub
End If
val = TextBox1.Value
myArray = Split(val, "\n")
For x = LBound(myArray) To UBound(myArray) 'define start and end of array
MsgBox (myArray(x))
Next x ' Loop!
End Sub
Bookmarks