Syncing a Shared Workbook Prior to Saving

Sonneillon

New Member
Joined
Nov 29, 2017
Messages
2
Hi,

I'm not really sure if this could be done; but I was wondering if there is a way to sync a shared workbook with all users before saving the workbook? At present, I am building a simple worksheet for team members to record the times they will be going on each day. We are limited to the amount of people who can be on break at the same time due to customer demand. I have a simple formula which flags a cell as false if too many people are on break at the same time, or if someone is trying to take too many breaks, and if the cell is false, the document won't save.

The problem I have is the team consists of 11 people, so there is a small potential that multiple people will book the same time -- too many on break at once and they will save the sheet, not knowing the time will become unavailable, which will cause the macro to break and corrupt the file. Is there an alternative to this? Perhaps an auto-save every minute, or a way to sync the spreadsheets before the save takes affect?

The macro I'm using at the moment:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If ActiveSheet.Range("A15").Value = ">1" Then
Cancel = True
MsgBox "Unable to Save, too many people on break at one time"
Next


If ActiveSheet.Range("A15").Value = ">1" Then
Cancel = True
MsgBox "Unable to Save, too many people on break at one time"
End If
End Sub

Many thanks if anyone is able to help :)
 

Some videos you may like

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Sonneillon

New Member
Joined
Nov 29, 2017
Messages
2
Ooops, copied the code wrong. The correct code is actually:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If ActiveSheet.Range("A15").Value = "1" Then
Cancel = True
MsgBox "Unable to Save - Too many people on are break at one time"
End If
If ActiveSheet.Range("AP15").Value = "1" Then
Cancel = True
MsgBox "Unable to Save - You have selected too many breaks"
End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,123,158
Messages
5,600,054
Members
414,357
Latest member
Gemma_R

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