Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Undo a change in a userform
Hello folks!
Is it possible undo a change from a combo box into a userform? For instance, if someone selects "A" in the list, the user must answer to a question to valid that he or she really wants to cancel. If the user hits No, I would like the program to bring back the value that was showing just before. Thanks, gmore |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Undo a change in a userform
Your post could have been much clearer, but I guessed that you may
want something like this. Private Sub ComboBox1_Change() Static aPrev As String iRtn = MsgBox("Are you sure?", vbYesNoCancel) If iRtn = 7 Then ComboBox1.Value = aPrev End If aPrev = ComboBox1.Value End Sub Hth, Merjet |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Undo a change in a userform
You can keep track of the current selection by placing it in a user form
variable. Something like this in your form code module would work: Private iCurrentIndex As Integer Private Sub ComboBox1_Change() If ComboBox1.ListIndex < iCurrentIndex Then If vbNo = MsgBox("Are you sure about this change?", vbYesNo) Then ComboBox1.ListIndex = iCurrentIndex 'put the old selection back End If End If End Sub Private Sub ComboBox1_Enter() iCurrentIndex = ComboBox1.ListIndex 'remember the current selection End Sub "gmore" wrote: Hello folks! Is it possible undo a change from a combo box into a userform? For instance, if someone selects "A" in the list, the user must answer to a question to valid that he or she really wants to cancel. If the user hits No, I would like the program to bring back the value that was showing just before. Thanks, gmore |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Undo a change in a userform
Thanks! It works fine.
"Vergel Adriano" wrote: You can keep track of the current selection by placing it in a user form variable. Something like this in your form code module would work: Private iCurrentIndex As Integer Private Sub ComboBox1_Change() If ComboBox1.ListIndex < iCurrentIndex Then If vbNo = MsgBox("Are you sure about this change?", vbYesNo) Then ComboBox1.ListIndex = iCurrentIndex 'put the old selection back End If End If End Sub Private Sub ComboBox1_Enter() iCurrentIndex = ComboBox1.ListIndex 'remember the current selection End Sub "gmore" wrote: Hello folks! Is it possible undo a change from a combo box into a userform? For instance, if someone selects "A" in the list, the user must answer to a question to valid that he or she really wants to cancel. If the user hits No, I would like the program to bring back the value that was showing just before. Thanks, gmore |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I undo or change emailing a worksheet | Excel Discussion (Misc queries) | |||
Undo function in Userform | Excel Programming | |||
undo a saved change | Excel Discussion (Misc queries) | |||
Undo Button Click change | Excel Discussion (Misc queries) | |||
Undo change | Excel Programming |