+ Reply to Thread
Results 1 to 3 of 3

Split listbox value in two textboxs

  1. #1
    Forum Contributor Marco-Kun's Avatar
    Join Date
    04-14-2009
    Location
    Holland
    MS-Off Ver
    Dutch:2007
    Posts
    298

    Split listbox value in two textboxs

    Hello everyone,

    I have a userform, with a listbox, with multiple items looking like this:
    1001 SB: Test1
    1002 SB: Test2
    1003 SB: Test3
    etc.

    Whenver I select one of these, I would like to have the value split to 2 different textboxes on the word document.
    Like this:
    Textbox 1: 1001
    Textbox 2: SB: Test1

    I know how I can get the data to one textbox, but I can't figure out how to split it.

    Please Login or Register  to view this content.
    Could this be achieved?

    Kind regards,

    Marco

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Split listbox value in two textboxs

    Hi

    Try this :

    Book1.xlsm

    Regards..
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Split listbox value in two textboxs

    Try:

    Dim Str as String
    Str = Me.ListBox1.Text
    ActiveDocument.FormFields("TextBox1").Result = Split(Str, " ")(0)
    ActiveDocument.FormFields("TextBox2").Result = Mid(Str, InStr(Str, " ") + 1, Len(Str))
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1