Macros and Combo boxes

J

Jeff F.

One thing I've tried without success is using combo boxes to make
selections to various macros. I can do these easily with radio
buttons (one button = one macro). Can combo boxes be used with
macros? Thanks!
 
G

George Clark

Jeff -

You can assign a macro to run when a selection is made (i.e., the selected
item is changed) in the ComboBox. You can then have that macro call other
macros if needed depending on the selected item. Would that accomplish what
you want, or did you have something else in mind?

George

One thing I've tried without success is using combo boxes to make
selections to various macros. I can do these easily with radio
buttons (one button = one macro). Can combo boxes be used with
macros? Thanks!

--
Mac Word FAQ: <http://www.mvps.org/word/FAQs/WordMac/index.html>
Entourage Help Page: <http://www.entourage.mvps.org/>
Or try Google: <http://www.google.com>

Please do not reply to this message. Although the email address is perfectly
valid, any replies to this account never get to the Inbox on my computer.
 
J

Jeff F.

Is this possible on a Mac? I was told that it wasn't possible since I
need VBA. Not sure how to make calls from a combo box to other
macros. Thanks for any help.
 
J

JE McGimpsey

Is this possible on a Mac? I was told that it wasn't possible since I
need VBA. Not sure how to make calls from a combo box to other
macros. Thanks for any help.

You can certainly use VBA with MacXL. The Combo box needs to be from the
Forms toolbar, since Macs don't support ActiveX controls.

Here's one way:

Create a combobox from the Forms toolbar, named Dropdown1.

Name a range of values for the dropdown, say, "srce_rng", and assign it
to the Combobox by CTRL-clicking Dropdown1 and selecting Format
Control...

In the Control tab of the Format dialog, enter srce_rng in the Input
Values textbox. Click OK.

Dropdown1's Value property will be an index into srce_rng.

You can access the chosen item by referencing the input values range.
Assign a macro something like this to the combobox (CTRL-click the
combobox and choose Assign macro):

Public Sub Dropdown_Change()
Dim db As DropDown
Set db = ActiveSheet.DropDowns(Application.Caller)
With db
MsgBox Range(.ListFillRange)(.ListIndex)
End With
End Sub
 
J

Jeff F.

JE McGimpsey said:
You can certainly use VBA with MacXL. The Combo box needs to be from the
Forms toolbar, since Macs don't support ActiveX controls.

Here's one way:

Create a combobox from the Forms toolbar, named Dropdown1.

Name a range of values for the dropdown, say, "srce_rng", and assign it
to the Combobox by CTRL-clicking Dropdown1 and selecting Format
Control...


In the Control tab of the Format dialog, enter srce_rng in the Input
Values textbox. Click OK.

Dropdown1's Value property will be an index into srce_rng.

You can access the chosen item by referencing the input values range.
Assign a macro something like this to the combobox (CTRL-click the
combobox and choose Assign macro):

Public Sub Dropdown_Change()
Dim db As DropDown
Set db = ActiveSheet.DropDowns(Application.Caller)
With db
MsgBox Range(.ListFillRange)(.ListIndex)
End With
End Sub


Thanks for your help! You probably know this, but the Win XL version
streamlines this process by enabling the number of drop down items, so
I guess that's a price one pays for using the Mac. It would be nice
if it were the same on the Mac.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top