Userform: MultiLine TextBox to Sheet Rows ?

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
785
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a MultiLine TextBox (TextBox1) on Userform1
And I'm trying to transfer each line of data to a sheet

Example - 5 lines from TextBox to cells ("A2:A6")

Does anyone know a way to do this?

Any help appreciated
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
The "lines" in a multiline textbox are not exactly lines. In the textbox you have a text string separated by the "enter key" (Char 10).

Try this:
VBA Code:
Private Sub CommandButton1_Click()
  Dim c As Variant, i As Long
  i = 2
  For Each c In Split(TextBox1, Chr(10))
    Range("A" & i).Value = c
    i = i + 1
  Next
End Sub

Or this:
VBA Code:
Private Sub CommandButton1_Click()
  Dim sStr As Variant
  sStr = Split(TextBox1, Chr(10))
  Range("A2").Resize(UBound(sStr) + 1).Value = Application.Transpose(sStr)
End Sub
 
Last edited:
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,814
Messages
6,121,711
Members
449,049
Latest member
THMarana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top