PDA

View Full Version : Solved: Multiline Textbox to Populate Multiple Cells



kiyiya
07-04-2008, 08:58 PM
I have a userform that creates a label and I have run into a snag.

There is a textbox on the form that can be up to 3 lines and I need the 3 lines to copy to 3 rows on the Label sheet when the Print Button is pushed. So far, my attempts have only allowed the 3 lines to print out on one row.

Can this be done or do I need to add a textbox for each line I need to transfer?

xld
07-05-2008, 01:33 AM
Dim aryLines As Variant

aryLines = Split(TextBox1.Text, vbNewLine)
Range("A1").Resize(UBound(aryLines) - LBound(aryLines) + 1) = Application.Transpose(aryLines)

kiyiya
07-05-2008, 05:10 AM
XLD,

I adjusted the range for the 3 rows I want to send my data to and it worked perfectly.

Thanks!

xld
07-05-2008, 06:04 AM
Why did you have to do that, I dynamically calculated them?

kiyiya
07-05-2008, 09:51 AM
I dunno! I just used the code supplied with the exception of modifying textbox1 to textbox3 and it only worked with the cell A1. Here is what I did to get it to work.
Dim aryLines As Variant
aryLines = Split(TextBox3.Text, vbNewLine)
Sheet7.Range("B8:B10").Resize(UBound(aryLines) - LBound(aryLines) + 1) = Application.Transpose(aryLines)

xld
07-05-2008, 10:25 AM
Try it with just



Dim aryLines As Variant
aryLines = Split(TextBox3.Text, vbNewLine)
Sheet7.Range("B8").Resize(UBound(aryLines) - LBound(aryLines) + 1) = Application.Transpose(aryLines)

kiyiya
07-05-2008, 11:00 AM
Perfect!

Ahmed Ali
10-06-2015, 12:40 PM
I have a similar query I have built a Data entry tool using Excel VBA user form for entering customer information. I used text boxes where user has to update 7 different fields and click on submit button which will save the data in worksheet. This is working good when there is single customer entry. For multiple entries the user have to update separately for each entry which is consuming time. Is there any option where text box with multiple columns where user can dump data from other sources into textbox and text box saves this into spreadsheet column and row wise.

Eg: If user is dumping below data into text box


Order No
Name
Product
City
P.No


4182
A
Keyboard
ABC
XXXXXXXX


23340
B
Table
DEF
XXXXXXXX


5439
C
Mouse
XYZ
XXXXXXXX


27377
D
Keyboard
XXX
XXXXXXXX


30147
E
Table
XXX
XXXXXXXX


34625
F
Mouse
XXX
XXXXXXXX