Reputation: 1435
Here's my sample output of split text using textbox and Button in Active X Control. As you can see here "Hello World!" was inputted in the text box and the output was splitted text.
But what I want is everytime that I input some data on textbox it gives splitted text continuously in other words the cell keeps the historical data that I inputted on the textbox.
Because it just give splitted text but not keeping it when entering new data on the textbox. I Want this output because I will use all of historical splitted text and count it after counting the most occurrence I will make a descriptive graph for my project
Here's my code:
Sub SplitText()
Dim TextString As String, WArray() As String, Counter As Integer, Strg As String
TextString = TextBox1
WArray() = Split(TextString, " ")
For Counter = LBound(WArray) To UBound(WArray)
Strg = WArray(Counter)
Cells(Counter + 2, 1).Value = Trim(Strg)
Next Counter
End Sub
Upvotes: 0
Views: 75
Reputation: 9898
You can do this without looping
Edit: Updated to append to end of column
Sub SplitText()
Dim WArray As Variant
WArray = Split(TextBox1, " ")
With Sheets("DatabaseStorage")
.Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).Resize(UBound(WArray) + IIf(LBound(WArray) = 0, 1, 0)) = Application.Transpose(WArray)
End With
End Sub
Upvotes: 1
Reputation: 1337
Sub SplitText()
Dim TextString As String, WArray() As String, Counter As Integer, Strg As String
TextString = TextBox1
WArray() = Split(TextString, " ")
For Counter = LBound(WArray) To UBound(WArray)
Strg = WArray(Counter)
Cells(Counter + 2, 1).Value = Trim(Strg)
Next Counter
Sheets("Original values").Range("A" & Sheets("Original values").Rows.Count).End(xlUp).Offset(1).Value = TextString
End Sub
Upvotes: 1