View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default message box popping up when the selection of a Form combo box chan

You said a Form Combo Box. I have assumed that you mean one that was created
from the Forms Tool bar and not one created from the Control Tool Box toolbar.

You need to have a linked cell which displays the number of any current
selection plus an additional cell on your worksheet to save the selection
each time it is changed. These can be anywhere out of site on the worksheet.

If you have not already got one then you need to set up the linked cell in
the combo box format control. You then need to initialize the other cell to
save the current selection by simply typing in the number to match the linked
cell. Note: A Forms Combo Box linked cell displays a number relating to the
selection, not the actual selection.

Then you could use a macro something like this:

Sub DropDown2_Change()
Dim msge
Dim style
msge = "Are you sure you want to switch the selection?"
style = vbYesNo

Response = MsgBox(msge, style)

If Response = vbYes Then
'Save the selection to a cell on worksheet
Sheets("Sheet1").Range("C1") = Sheets("Sheet1").Range("B1")
'At this point you may call another
'procedure to run because of the change
'or do nothing
Else
'Revert to previous selection. Changing the linked cell number
'changes the selection in the Combo Box.
Sheets("Sheet1").Range("B1") = Sheets("Sheet1").Range("C1")
Exit Sub 'Terminate any further processing
End If
End Sub


Regards,

OssieMac

"George" wrote:

All:

I have a Form Combo Box. There are three option inside the box for me
to select. Definitely, one option will be visible and the other two
options will be Invisible unless I click the combo box. What I am
trying to do is whenever I click the combo box and select one option
which is different from the PREVIOUS VISIBLE one, I want a simple
message of "Are you sure you want to switch the selection"?

Please advise!