Copy from various text boxes to one text box - formating

harveya915

Board Regular
Joined
Sep 4, 2015
Messages
141
I have a UserForm that contains TextBoxes 1-3. I have a command button that when clicked will copy whatever is on TextBoxes 1-3 to TextBox4. The issue I have is that I want for the contents of boxes 1-3 are entered but each on it's own line. Right now I have for all text to come out consecutively. This is the code I have:

VBA Code:
Private Sub CommandButton1_Click()
TextBox4.Value = TextBox1.Text & " " & "Received Agent Copy" & " " & TextBox2.Text & "Installment Amount" & TextBox3.Text
End Sub

So basically as an example I will get the following result (all in one consecutive line):
Box1 Contents Received Agent Copy Box2 Contents Installment Amount $100.00

The result I want is (separate lines):
Box1 Contents
Received Agent Copy Box2 Contents
Installment Amount $100.00

I'm a noob at this, I learn by searching.
Any help would be gladly appreciated.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Did some searching and found this works. add vbNewLine where you want a new line to be inserted:
VBA Code:
Private Sub CommandButton1_Click()
TextBox4.Value = TextBox1.Text & vbNewLine & "Received Agent Copy" & " " & "TextBox2.Text & vbNewLine & "Installment Amount" & " " & TextBox3.Text
End Sub
Hope this helps someone out.
 
Upvote 0

Forum statistics

Threads
1,215,779
Messages
6,126,842
Members
449,343
Latest member
DEWS2031

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