+ Reply to Thread
Results 1 to 2 of 2

vba-Select from combobox,display in listbox

  1. #1
    Registered User
    Join Date
    10-07-2008
    Location
    Singapore
    Posts
    11

    Question vba-Select from combobox,display in listbox

    hi, thanks for taking time to help me out

    scenario
    i have a year combobox with values 2007, 2008, 2009, 2010 etc
    once i select a year eg 2007 and click search, i want a search to look thru all the worksheets in my workbook.
    All my sheets are named(1-jan-2007, 4-feb-2007 etc) so when the user selects 2007, i want only that particular years sheets to be displayed in the listbox... how do i do that? once tat is done, i should be able to click on the worksheets appearing in the listbox and on clickin ok, the particular wksheet pops up...is it possible?


    so far i have this:
    Private Sub UserForm_Activate()

    With YEAR_COMBO 'this adds the following data into the combo box
    .AddItem "2007"
    .AddItem "2008"
    .AddItem "2009"
    .AddItem "2010"

    End With
    End Sub


    Private Sub UserForm_Initialize()
    Dim ws As Worksheet 'Declaring that ws is term going to be used to refer to worksheets'
    For Each ws In ThisWorkbook.Worksheets 'for each wksheet in the current workbk, add the wksheet name to the listbox'
    ListBox1.AddItem (ws.Name)
    Next ws 'add the next worksheet til last one available is listed'
    End Sub
    Last edited by ACOM; 05-16-2009 at 03:48 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: vba-Select from combobox,display in listbox

    ACOM please adhere to the Forum Rules...

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

+ 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