Consulting

Results 1 to 8 of 8

Thread: Solved: Multiline Textbox to Populate Multiple Cells

  1. #1
    VBAX Regular
    Joined
    Jun 2008
    Posts
    53
    Location

    Solved: Multiline Textbox to Populate Multiple Cells

    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?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Dim aryLines As Variant

    aryLines = Split(TextBox1.Text, vbNewLine)
    Range("A1").Resize(UBound(aryLines) - LBound(aryLines) + 1) = Application.Transpose(aryLines)
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Jun 2008
    Posts
    53
    Location
    XLD,

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

    Thanks!

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Why did you have to do that, I dynamically calculated them?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Regular
    Joined
    Jun 2008
    Posts
    53
    Location
    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.
    [VBA]Dim aryLines As Variant
    aryLines = Split(TextBox3.Text, vbNewLine)
    Sheet7.Range("B8:B10").Resize(UBound(aryLines) - LBound(aryLines) + 1) = Application.Transpose(aryLines)[/VBA]

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try it with just

    [vba]

    Dim aryLines As Variant
    aryLines = Split(TextBox3.Text, vbNewLine)
    Sheet7.Range("B8").Resize(UBound(aryLines) - LBound(aryLines) + 1) = Application.Transpose(aryLines)
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Regular
    Joined
    Jun 2008
    Posts
    53
    Location
    Perfect!

  8. #8
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •