Activex combobox in Excel

Posted on 2009-02-24
Last Modified: 2013-11-18
If my understanding is correct for this to work, a Private Sub must be in the same Sheet as the combobox. From there, how do I pass the value selected from the combobox to a normal macro contained in a module? I really don't understand all the Public/Private stuff. Thanks.
Question by:trekrok
    LVL 50

    Accepted Solution

    You could do it as per the code below (see sample file).  On the ComboBox change event a string with the combobox value is sent to the main sub
    Note you could also just return the value from the combobox linked cell in B1

    'In sheet code
    Option Explicit
    Private Sub ComboBox1_Change()
    Call MainSub(ComboBox1.Value)
    End Sub
    ' In module
    Sub MainSub(myStr As String)
    MsgBox "User picked " & myStr
    End Sub

    Open in new window


    Author Closing Comment

    LVL 50

    Expert Comment

    by:Dave Brett
    thx for the grade

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
    Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
    The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
    The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now