+ Reply to Thread
Results 1 to 6 of 6

Populate Excel Userform with Sheet names

  1. #1
    PC
    Guest

    Populate Excel Userform with Sheet names

    Hi,

    I'm using this piece of code to populate an excel userform listbox with the
    name of each worksheet in a workbook

    i = 1
    For Each ws In Worksheets
    Worksheets.Select
    Sheets(i).Activate
    ListBox1.AddItem (ActiveSheet.Name)
    i = i + 1
    Next ws


    Is there a better way I can do this as this visably activates each
    sheet each time the listbox is repopulated.

    Thanks

    ...pc



  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello PC,

    Paste this code into your program.

    I = 1
    For Each ws In Worksheets
    ComboBox1.AddItem (Sheets(I).Name)
    I = I + 1
    Next ws

    Hope this helps,
    Leith Ross

  3. #3
    Dick Kusleika
    Guest

    Re: Populate Excel Userform with Sheet names

    PC

    For Each ws In ActiveWorkbook.Worksheets
    ListBox1.AddItem ws.Name
    Next ws

    --
    **** Kusleika
    Excel MVP
    Daily Dose of Excel
    www.*****-blog.com

    PC wrote:
    > Hi,
    >
    > I'm using this piece of code to populate an excel userform listbox
    > with the name of each worksheet in a workbook
    >
    > i = 1
    > For Each ws In Worksheets
    > Worksheets.Select
    > Sheets(i).Activate
    > ListBox1.AddItem (ActiveSheet.Name)
    > i = i + 1
    > Next ws
    >
    >
    > Is there a better way I can do this as this visably activates each
    > sheet each time the listbox is repopulated.
    >
    > Thanks
    >
    > ..pc




  4. #4
    Registered User
    Join Date
    04-23-2013
    Location
    Jordan
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Populate Excel Userform with Sheet names

    this is good code
    Please Login or Register  to view this content.
    now how to add double click on the sheet in the list box and open this sheet ???
    any Idea's ??
    or is it possible ?

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Populate Excel Userform with Sheet names

    Shacker,

    This thread is 8 yrs old. Please create a new thread for yourself.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  6. #6
    Registered User
    Join Date
    04-23-2013
    Location
    Jordan
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Populate Excel Userform with Sheet names

    8 years ???

    lol, Sorry , i dodn't notice that :D

    will do another one now , thank you

+ 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