ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Re-setting Forms Spinners or Combo-Boxes (https://www.excelbanter.com/excel-programming/400439-re-setting-forms-spinners-combo-boxes.html)

Marie

Re-setting Forms Spinners or Combo-Boxes
 
Is there any way of re-setting spinners of combo-boxes back to zero easily
with one click instead of having to change each one individually?

I am trying to create a form which requires selecting how many quantities
you want and want to be able to save over the excel document, open it up
re-set everything to zero and re-use it rather than having to save the
document as something else and keeping a master document.

I hope this makes sense, any help would be greatfully received!

John Bundy

Re-setting Forms Spinners or Combo-Boxes
 
Just put a reset button on the form and set its on click event to set each
item to zero.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Marie" wrote:

Is there any way of re-setting spinners of combo-boxes back to zero easily
with one click instead of having to change each one individually?

I am trying to create a form which requires selecting how many quantities
you want and want to be able to save over the excel document, open it up
re-set everything to zero and re-use it rather than having to save the
document as something else and keeping a master document.

I hope this makes sense, any help would be greatfully received!


Incidental

Re-setting Forms Spinners or Combo-Boxes
 
Hi Marie

one way to do it would be to set all the default values in the
userform_initilize event then set a button to call it to reset the
form

Private Sub CommandButton1_Click()
UserForm_Initialize
End Sub

Private Sub SpinButton1_SpinDown()
ComboBox1.ListIndex = ComboBox1.ListIndex - 1
End Sub

Private Sub SpinButton1_SpinUp()
ComboBox1.ListIndex = ComboBox1.ListIndex + 1
End Sub

Private Sub UserForm_Initialize()
ComboBox1.List = Array("1", "2", "3", "4", "5", "6", "7")
ComboBox1.ListIndex = 0
SpinButton1.Value = 0
End Sub

hope this helps



Marie

Re-setting Forms Spinners or Combo-Boxes
 
Thanks for this. Do you know if you can re-set combo or list boxes as well?

"Incidental" wrote:

Hi Marie

one way to do it would be to set all the default values in the
userform_initilize event then set a button to call it to reset the
form

Private Sub CommandButton1_Click()
UserForm_Initialize
End Sub

Private Sub SpinButton1_SpinDown()
ComboBox1.ListIndex = ComboBox1.ListIndex - 1
End Sub

Private Sub SpinButton1_SpinUp()
ComboBox1.ListIndex = ComboBox1.ListIndex + 1
End Sub

Private Sub UserForm_Initialize()
ComboBox1.List = Array("1", "2", "3", "4", "5", "6", "7")
ComboBox1.ListIndex = 0
SpinButton1.Value = 0
End Sub

hope this helps




Incidental

Re-setting Forms Spinners or Combo-Boxes
 
Hi Marie

You can reset both combo and listboxes by setting their list index to
-1, putting the code below in the code for the reset button or
userform_initialize event (depending on which option you went with
from above) should do the trick

ComboBox1.ListIndex = -1
ListBox1.ListIndex = -1

hope this helps

steve



Marie

Re-setting Forms Spinners or Combo-Boxes
 
Great, thanks!

"Incidental" wrote:

Hi Marie

You can reset both combo and listboxes by setting their list index to
-1, putting the code below in the code for the reset button or
userform_initialize event (depending on which option you went with
from above) should do the trick

ComboBox1.ListIndex = -1
ListBox1.ListIndex = -1

hope this helps

steve




aaaa

Re-setting Forms Spinners or Combo-Boxes
 
Thanks. This is helpful to me as well.

"Incidental" wrote:

Hi Marie

You can reset both combo and listboxes by setting their list index to
-1, putting the code below in the code for the reset button or
userform_initialize event (depending on which option you went with
from above) should do the trick

ComboBox1.ListIndex = -1
ListBox1.ListIndex = -1

hope this helps

steve





All times are GMT +1. The time now is 09:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com