Link a Spinner to a combo box control

T

Tim

Hi all,

I don't know if my terminology is correct ( i am going by what pops up
when I hold my mouse over the controls on the control tool bar) but I
am having trouble linking a spinner to a combo box on a worksheet. What
i want is a way for a user to cycle through the values in the combo box
using the spinner. I am sure there should be an easy way to do this but
for now I am stumped. I have tried linking them both to the same cell
which works ok if I change the cell value manually but if I change it
using the spinner the combo box does not update. Strangely if I change
the choice in the combo box this updates the value of the spinner but
not the other way around. Am I missing something fundamental?

Any help appreciated

Cheers

Tim
 
D

Dave Peterson

The linkedcell for the combobox from the control toolbox toolbar will contain
the value of the combobox.

The linkedcell for the spinner from the control toolbox toolbar will contain a
number.

Unless your combobox contains the same numbers that the spinner uses (and in the
same order), you'll need more than a linkedcell to do what you want.

But if you use the dropdown and spinner from the Forms toolbar, the linkedcell
process will work nicely. (The linkedcell for a dropdown from the forms toolbar
returns a number--the index into that dropdown's list.

And make sure that the spinner's min is 1 and max is the number of items in the
list.

=====
If you're set on using the controls from the Control toolbox toolbar, you could
drop the linked cell and use code that does the work.

This goes under the worksheet that holds the combobox and spinner:

Option Explicit
Private Sub ComboBox1_Change()
Me.SpinButton1.Value = Me.ComboBox1.ListIndex
End Sub
Private Sub SpinButton1_Change()
Me.ComboBox1.ListIndex = Me.SpinButton1.Value
End Sub


But this time, make the spinner go from 0 to number of options minus 1.
(10 items in the combobox, then go from 0 to 9)
 

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