Reputation: 754
Can I loop through a Textbox for each line entered and format it? For example if the user entered:
Text1
Text2
I would like to output it as in a single line.
'Text1','Text2'
Also would be awesome if you can get the last comma to not display.
Upvotes: 1
Views: 1092
Reputation: 306
This is what you really need
Add a textbox to your sheet
Add this code on TextBox1_Change() event
Dim mystr
mystr = Split(Sheet1.TextBox1.Text, vbCrLf)
Sheet1.Range("A1") = "'" & Join(mystr, "','") & "'"
Right click to textbox and enable multiline option
Control + Enter to change line inside textbox
And you have the result that you want:
Upvotes: 3