LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default combobox after change but user hits cancel to message box

the code below is used to save some data when a user changes months on a
combobox. The code prompts the user to see if he/she wants to save the
estimates with a Yes, No, Cancel.

yes and no cases work as expected but when the user clicks cancel, the code
exits out as expected but the combox box value is now set to the new month
the user selected. I would like it to be set back to the month they had in
the combox before the changed it.

how can I do modify the code to do that or is there a better way to do this?

thanks

Private Sub cboMonth_Change()
Dim myCheck As Integer
Dim ms As String
Dim dc As Long

On Error Resume Next
Application.ScreenUpdating = False

ms = Format(Range("cyMonthSave"), "mmm")

With Sheets("Estimates")

'finds appropriate column
dc = .Rows(1).Find(What:=ms, LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Column

End With
If Sheets("Merchandise Store Plan").Range("m15").Value =
Sheets("Estimates").Cells(60, dc).Value Then
GoTo SkipChanges:
End If

myCheck = MsgBox("Do you want to save your changes?", vbYesNoCancel, "Save")

If myCheck = vbCancel Then
Exit Sub
Else
If myCheck = vbNo Then
GoTo SkipChanges:
End If
End If

mcrSaveEstimates

'No changes to save
SkipChanges:

Range("A2") = Sheets("Misc").Range("CYMonth").Value
Range("A3") = Sheets("Misc").Range("PYMonth").Value

'brings back previosly saved estimated for the new month selected
RestoreEstimates

Application.ScreenUpdating = True
Beep
End Sub
 
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
User hits Cancel The Inspector[_2_] Excel Programming 3 June 29th 09 12:58 PM
Relacing default Excel message box when user attempts to change locked cell on protected sheet. Chrisso Excel Programming 2 March 19th 07 04:55 PM
Cancel Macro is user selects 'cancel' at save menu Mark Excel Programming 1 April 6th 05 05:45 PM
Cancel Message Howard Excel Discussion (Misc queries) 1 December 21st 04 04:31 PM
Dialog Box - User hits cancel CS[_2_] Excel Programming 4 November 14th 03 10:05 PM


All times are GMT +1. The time now is 04:30 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"