+ Reply to Thread
Results 1 to 6 of 6

ListBox

  1. #1
    Registered User
    Join Date
    06-19-2010
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    8

    ListBox

    I am new to vba. i have big workbook with 200 sheets - need vba code to populate listbox ( or combobox) with sheetnames. Then i need to go to sheet if i click on sheetname. new sheets are added, old ones deleted. Please help.

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: ListBox

    Hi
    1. Press Alt+F11 Go to Insert and choose Userform
    2. Insert Listbox cotrol to the userform
    3. Double click o the userform (VBE will open)
    4. Paste this code there
    Please Login or Register  to view this content.
    1. Close VBE
    2. Insert a button and double click it
    3. Paste this code
      Please Login or Register  to view this content.
    4. Close VBE and Press DesignView Button so that button become clickable

    Ready. Dummy is attached..
    HTH
    Attached Files Attached Files
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: ListBox

    This is a built-In facility in Excel.

    go to scrollbuttons on the pagetab, (left lower corner of the window)
    rightclick your mouse
    choose the desired sheet.

  4. #4
    Registered User
    Join Date
    06-19-2010
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: ListBox

    Quote Originally Posted by contaminated View Post
    Hi
    1. Press Alt+F11 Go to Insert and choose Userform
    2. Insert Listbox cotrol to the userform
    3. Double click o the userform (VBE will open)
    4. Paste this code there
    Please Login or Register  to view this content.
    1. Close VBE
    2. Insert a button and double click it
    3. Paste this code
      Please Login or Register  to view this content.
    4. Close VBE and Press DesignView Button so that button become clickable

    Ready. Dummy is attached..
    HTH
    Thanks a huge lot - this is exactly what I need - just one more step - if i click for eg on sheet2, i need to work on sheet 2. So how can i close the userform ( with the code) after i clik on eg sheet 2?

  5. #5
    Registered User
    Join Date
    08-16-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: ListBox

    Hey, you can use multiple ways do close it, either you can just create a button on the UserForm underneath for example the listbox or you can tell it programmatically that once you clicked on one of the selection option in the listbox to close down the UserForm.

    This will close down the Userform after selecting a tab:

    Please Login or Register  to view this content.
    If you use the button approach just set up a button and add the code Unload Me on the actioncode.

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: ListBox

    Maybe this is even more what you need (instead of using Excel's built-in facilities)
    It's implemented in the attachment.

    1. make a dropdownlist in the MenuBar (scrutinize the name of the personal workbook !)

    Please Login or Register  to view this content.
    2. Put this code in the workbook you want its sheets being displayed in the dropdownlist in the Menubar

    Please Login or Register  to view this content.
    3. put this macro in your personal.xls

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by snb; 08-17-2010 at 05:08 AM.

+ 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