Message if Shared Workbook is deselected

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,046
I have a spreadsheet which is a Shared workbook. As this tracks the history of what happens to the spreasheet, If someone tries to deselect it I want a message to appear to with a YES and NO option button, so if they have not copied the history data the shared workbook remains, if they have copied the data and then click yes the shared workbook then becomes unticked and therfore exclusive...any ideas ?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
Something like this ? Copy/paste code to worksheet module (rightclick tab/View code)
Code:
Private Sub Worksheet_Deactivate()
   rsp = MsgBox("Deactivated. Save changes ?", vbYesNoCancel)
   If rsp = vbCancel Then Exit Sub
   If rsp = vbYes Then
        'do something
   Else
        ' do something else
   End If
End Sub
 

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,046
Ive inserted a module and copied this code across but nothing happens when I deselect the box ?
 

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,046
Any ideas how I can get this code to work please ??


Thanks

Paul
 

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
The code does not do anything as it stands - except it runs when the someone moves away from the sheet it is contained in to another one. There is a similar possibility for the workbook. It is necessary to replace "'do something " and "'do something else" with appropriate code.

Apart from that I do not know codewise what you are trying to achieve. A way forward would be to record macros of the 2 possibilities and come back with any problems.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,130
Messages
5,857,550
Members
431,885
Latest member
Rsdg

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top