+ Reply to Thread
Results 1 to 4 of 4

ListBox to TextBox on worksheet

  1. #1
    Registered User
    Join Date
    07-16-2016
    Location
    Belo Horizonte, Brazil
    MS-Off Ver
    2016
    Posts
    22

    ListBox to TextBox on worksheet

    Greetings everyone,

    I've recently started programming with VBA outside of UserForms and directly on the worksheets. I'm struggling however with populating a TextBox based on ListBox.Click.

    Let's say for instance my ListBox is filled with all the information from Worksheet 1, column A and I want the TextBox to show me whatever information I have on column B of the same row as the selected ListBox item.

    On UserForm I'm used to achieve this by using ListBox_Click and Textbox1.value equals ListBox1.item + offset

    How could this be done in the worksheet?

    Thanks everyone!

    Repost from Mr Excel Forum under #post 5259203

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: ListBox to TextBox on worksheet

    Load both columns in ListBox and use the Click-event of the ListBox to send the information to the TextBox.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Registered User
    Join Date
    07-16-2016
    Location
    Belo Horizonte, Brazil
    MS-Off Ver
    2016
    Posts
    22

    Re: ListBox to TextBox on worksheet

    Hey! Thanks for your reply!

    This is what I've been trying, however it fails to identify the range. Any thoughts?


    Private Sub ListBox1_Click()
    With ListBox1
    TextBox_Detail.ScrollBars = fmScrollBarsVertical
    TextBox_Detail.MultiLine = True
    TextBox_Detail.WordWrap = True
    TextBox_Name.Value = Range(.List(.ListIndex, 1)).Offset(, 1).Value
    TextBox_Detail.Value = Range(.List(.ListIndex, 1)).Offset(, 2).Value
    End With
    End Sub

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: ListBox to TextBox on worksheet

    What's the code you use to load the ListBox ?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA - Userform - Listbox validation and Listbox to Textbox
    By stevefisher85 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2016, 07:11 AM
  2. Replies: 4
    Last Post: 12-29-2014, 02:46 PM
  3. Replies: 4
    Last Post: 01-29-2014, 05:53 AM
  4. Listbox, textbox and cell worksheet
    By hitmen in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-20-2014, 07:39 AM
  5. VBA - Macro Code to copy textbox text to another worksheet textbox
    By nitram lowm in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-05-2013, 08:39 AM
  6. Macro to copy textbox data to a duplicate textbox in another worksheet
    By nitram lowm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-02-2013, 06:10 AM
  7. Userform to search textbox value to place other textbox values in worksheet
    By mattyh555 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-19-2012, 11:38 AM

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