Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Vancouver, Canada
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro for on-sheet combo box (Excel XP)

    I have an on-sheet combo box which contains a list of stocks. I would like to be able the choose a stock from the list, and based on the selection, have Excel go to the sheet for that particular stock. I have written a macro similar to this before using the cell link as a reference...but in this instance...the list is sorted alphabetically everytime the a new stock is added so using the cell link in the manner I did before will not work.

    Thanks in advance for any help.

    Christa

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro for on-sheet combo box (Excel XP)

    If the names in the Combobox are the same as the sheet names, then you could put some code like this in the combobox lost focus event routine.

    <pre>Private Sub ComboBox1_LostFocus()
    Dim oSheet As Worksheet
    Set oSheet = Nothing
    On Error Resume Next
    Set oSheet = Worksheets(ComboBox1.Text)
    On Error GoTo 0
    If Not oSheet Is Nothing Then
    oSheet.Activate
    End If
    End Sub
    </pre>

    Legare Coleman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •