+ Reply to Thread
Results 1 to 12 of 12

'Connect' two listboxes

  1. #1
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    'Connect' two listboxes

    Hi all,

    I have Listbox1 which shows the values in columns D to I. The info in column J I want to show in another Listbox (the reason being is a design one as the length of string is quite long).

    I am trying to ‘connect’ the two list-boxes together so that when Listbox1 is scolled up/down then Listbox2 follows suit. I have tried using the Initialize event to call a Vlookup but I can’t seem to get it to work. Any ideas?

    Please Login or Register  to view this content.
    This is my working Listbox1 code:

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: 'Connect' two listboxes

    In Initialize event Listbox2 will have Listindex -1 unless you change it. You may add code to Listbox1 click event to populate listbox2 - it will be simple if you will populate listbox1 with all data and then you may simply assign chosen column to listbox2. However I think multi-line Textbox may be simpler.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: 'Connect' two listboxes

    Thank you Izandol. That makes sense. I'll try and work it out. : )

  4. #4
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: 'Connect' two listboxes

    Hi Izandol,

    I tried putting this at the bottom of the Listbox1 sub but no good. In fact I can't work out how to assign anything to a LB. I'm not a heavy user of forms.

    Private bSkipEvents As Boolean

    Please Login or Register  to view this content.

  5. #5
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: 'Connect' two listboxes

    Which column will be added to Listbox2? Also, if you are adding to listbox control, I assume there should be more than one item? Therefore probably you will need Split:
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: 'Connect' two listboxes

    Hi,

    Column J.

    At the moment ListBox1 shows everything I need (D2:J50). Essentially I want ListBox2 to show the 'J' and LB1 to show D:I.

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: 'Connect' two listboxes

    Did you test the code I have posted in last post?

  8. #8
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: 'Connect' two listboxes

    It works! Woo! Sorry forgot to test.

    I don't want to push your generosity but can I make the text wrap within the listbox (i.e. - over more than one line)?

  9. #9
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: 'Connect' two listboxes

    It will split on line feed character (Alt + Enter in cell). If you do not have this, you must decide how to split?

  10. #10
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404
    I see. I'd probably want to split it every nth character. Possibly every hundredth. : )

  11. #11
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: 'Connect' two listboxes

    May you not use multi-line textbox or simple textbox with wrap text option?

  12. #12
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: 'Connect' two listboxes

    Ahh yes, of course. Thank you VERY much Izandol. Very kind.

+ 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. Connect 2 listboxes
    By D_N_L in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2014, 01:07 PM
  2. From one into 4 listboxes
    By jrkraucher in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2013, 01:58 PM
  3. Need help with Listboxes!
    By Angelus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-24-2006, 12:50 AM
  4. [SOLVED] listboxes
    By john.9.williams@bt.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-30-2005, 02:06 PM
  5. [SOLVED] listboxes
    By john.9.williams@bt.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2005, 12:06 PM

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