Activex combobox in Excel

Posted on 2009-02-24
Medium Priority
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
  • 2
LVL 50

Accepted Solution

Dave Brett earned 2000 total points
ID: 23723414
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

ID: 31550642
LVL 50

Expert Comment

by:Dave Brett
ID: 23723884
thx for the grade

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
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…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

840 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