+ Reply to Thread
Results 1 to 8 of 8

Displaying item from a listbox in a textbox with next 2 columns

  1. #1
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Displaying item from a listbox in a textbox with next 2 columns

    Hello

    I have a listbox (listbox5), the source of the listbox is range "a5:a10". Is it possible that when i click on an item in the listbox, can I use a command click event from a button to display the item in a textbox along with the information in the same row up to column "C".

    So to simplify, the row source is "a5:a10", if the item i selcetd in the listbox is at "a6", then i want the textbox to display "A6:C6" via click event from command button
    Last edited by kmakjop; 06-25-2014 at 12:49 PM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Displaying item from a listbox in a textbox with next 2 columns

    I would use a three column Listbox
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Re: Displaying item from a listbox in a textbox with next 2 columns

    Thank you for responding, i am getting an error message for the code you gave:

    Please Login or Register  to view this content.

    However if i take out the last two me.textbox2 and me.textbox3, then it works, not sure why. I entered the code just as you told me and initialized the page as you have it there. But my list box doesnt come up with three columns, is that who it should be? i am wondering if thats where the problem is. the code below is what works, but what you suggested is not.

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Re: Displaying item from a listbox in a textbox with next 2 columns

    Thank you for responding, i am getting an error message for the code you gave:

    Please Login or Register  to view this content.

    However if i take out the last two me.textbox2 and me.textbox3, then it works, not sure why. I entered the code just as you told me and initialized the page as you have it there. But my list box doesnt come up with three columns, is that who it should be? i am wondering if thats where the problem is. the code below is what works, but what you suggested is not.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    (Solved) Displaying item from a listbox in a textbox with next 2 columns

    Please ignore previous posts Issue solved thank you

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    re: Displaying item from a listbox in a textbox with next 2 columns

    The invisible columns of the ListBox were hidden by the .ColumnWidths statement.

    I'm guessing that you're result involved something like
    Please Login or Register  to view this content.
    You also might want to look at the BoundColumn and TextColumn properties of a multi-column listbox, you might find them useful.

  7. #7
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    re: Displaying item from a listbox in a textbox with next 2 columns

    I did exactly what you suggested, use three different text boxes. The difference was i just changed the row source for each list box and let each list box populate its own text box. I know its the noob way but, i am learning VBA through my errors and what you guys in here teaches. Thanks again man.

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Displaying item from a listbox in a textbox with next 2 columns

    About your "noob way". Its perfect.

    Code that you can understand is the best code. Far better than efficient, concise, robust code that you don't understand.

+ 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. [SOLVED] Display Selected Item in Listbox in Textbox
    By puuts in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-14-2014, 04:19 PM
  2. [SOLVED] Displaying last 5 value of an excel column to a textbox or listbox
    By nathan0519 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2014, 02:27 AM
  3. Select listbox item then appear textbox
    By sohaila in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-01-2013, 04:41 AM
  4. [SOLVED] Displaying data from different columns in listbox
    By pezalmendra in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2012, 05:47 PM
  5. Retaining focus on a textbox / listbox item pair after validation = false.
    By chatterbox in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2006, 06:50 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