PDA

View Full Version : [SOLVED:] How to sync a spin button and combo box, so they always have the same value?



Zuccj
06-30-2017, 04:42 AM
I have a combobox that I'm using a spinbutton to control. It all works fine except for if you use the arrow keys on the keyboard to change the combobox the spinbutton doesn't update with that new value, so when you hit spinbutton again the number jumps back to what it was before using the keyboard. I would like for these two to always be synced and when one is changed the other is changed as well.

This is how I'm updating the combox from the spinbutton

Private Sub SpinButton1_Change()
With ComboBox1
.ListIndex = SpinButton1
End With
End Sub

This is one way I tried to link the combox to the spinbutton

Private Sub combox1_change()
With SpinButton1
SpinButton1.value = Sheet2.Cells(1, "AZ").value
End With
End Sub


the other way I've tried

Private Sub combox1_change()
With SpinButton1
SpinButton1.value = ComboBox1.value
End With
End Sub


The value in the combobox is sent to cell AZ1, which is why I tried pulling from that cell as well as the box itself. So far I haven't had any luck with getting them synced and not sure why.

snb
06-30-2017, 05:19 AM
Please check your spelling !!


Private Sub comboBox1_change()
SpinButton1.value = combobox1.listindex
End Sub

Zuccj
06-30-2017, 05:33 AM
That worked thanks.