+ Reply to Thread
Results 1 to 5 of 5

List box to Text Box

  1. #1
    mully
    Guest

    List box to Text Box

    Hi

    On a userform I have a list box that consists of 4 columns e.g.

    121 - Joe Bloggs - 493 -1647

    I would like to do the following on the same userform after highligting the
    line
    121 - Joe Bloggs - 493 - 1647 - in the list box.

    TextBox1 = 121
    TextBox2 = Joe Bloggs
    TextBox3 = 493
    TextBox4 =1647

    all I end up with when trying to do it is that all the TextBoxes have 121
    in them

    Any help to solve this problem is much appreciated

    Mully



  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning Mully

    This piece of code should help, in your Userorm_Initialize:

    Private Sub UserForm_Initialize()
    TextBox1 = ActiveCell.Value
    TextBox2 = ActiveCell.Offset(, 1).Value
    TextBox3 = ActiveCell.Offset(, 2).Value
    TextBox4 = ActiveCell.Offset(, 3).Value
    End Sub

    HTH

    DominicB

  3. #3
    mully
    Guest

    Re: List box to Text Box


    Good Morning Dominic

    Thanks for the help installed the code as you recommended and on opening
    the UserForm showed all the details from the Row on the Active Sheet and on
    clicking the command button "Add Info" it put the row details on another
    sheet correctly.
    However on highlighting a row in the List Box no details showed in the text
    boxes I had to go back to the sheet select a row and the new details showed.
    What I wanted to do was get the details from the List Box on the UserForm and
    just click "Add Info" Is this possible ????

    Thanks Mully

    "dominicb" wrote:

    >
    > Good morning Mully
    >
    > This piece of code should help, in your Userorm_Initialize:
    >
    > Private Sub UserForm_Initialize()
    > TextBox1 = ActiveCell.Value
    > TextBox2 = ActiveCell.Offset(, 1).Value
    > TextBox3 = ActiveCell.Offset(, 2).Value
    > TextBox4 = ActiveCell.Offset(, 3).Value
    > End Sub
    >
    > HTH
    >
    > DominicB
    >
    >
    > --
    > dominicb
    > ------------------------------------------------------------------------
    > dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
    > View this thread: http://www.excelforum.com/showthread...hreadid=393594
    >
    >


  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi Mully

    Apologies for the delay in my reply.

    It depends on exactly how you've set up your list box, but I've just tested this piece of code and it seemed to be working OK - is this what you wanted?

    Private Sub ListBox1_Click()
    TextBox1.Value = ListBox1.List(, 0)
    TextBox2.Value = ListBox1.List(, 1)
    TextBox3.Value = ListBox1.List(, 2)
    TextBox4.Value = ListBox1.List(, 3)
    End Sub

    HTH

    DominicB

  5. #5
    mully
    Guest

    Re: List box to Text Box

    Hi Dominic
    Been busy myself -- out all morning.

    Just the job and spot on -- thanks for all your help

    much appreciated

    Mully

    "dominicb" wrote:

    >
    > Hi Mully
    >
    > Apologies for the delay in my reply.
    >
    > It depends on exactly how you've set up your list box, but I've just
    > tested this piece of code and it seemed to be working OK - is this what
    > you wanted?
    >
    > Private Sub ListBox1_Click()
    > TextBox1.Value = ListBox1.List(, 0)
    > TextBox2.Value = ListBox1.List(, 1)
    > TextBox3.Value = ListBox1.List(, 2)
    > TextBox4.Value = ListBox1.List(, 3)
    > End Sub
    >
    > HTH
    >
    > DominicB
    >
    >
    > --
    > dominicb
    > ------------------------------------------------------------------------
    > dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
    > View this thread: http://www.excelforum.com/showthread...hreadid=393594
    >
    >


+ 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