Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I undo or change emailing a worksheet Kirk Excel Discussion (Misc queries) 2 May 21st 08 07:30 PM
Undo function in Userform Tyro[_5_] Excel Programming 4 September 12th 06 05:54 PM
undo a saved change gl kruger Excel Discussion (Misc queries) 2 April 11th 06 10:43 PM
Undo Button Click change Kiran Excel Discussion (Misc queries) 2 July 12th 05 07:59 PM
Undo change Bhuktar S[_5_] Excel Programming 1 April 26th 04 05:46 AM


All times are GMT +1. The time now is 12:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"