Worksheet only open by one person at a time

steventnorris

New Member
Joined
Feb 15, 2013
Messages
2
I want to limit a workbook to only be open by one person at a time. I know it default to allow read-only access, but I am running a lot of VBA from button clicks that should only be usable by one person on a first-come-first-serve basis. How can I lock out all other users when the excel workbook is already opened by another user?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Welcome to the board!

Whack this code in the ThisWorkbook module:
Code:
Private Sub Workbook_Open()
    With Me
        If .ReadOnly Then
            Call MsgBox(Prompt:="The workbook is already open by another user!", _
                        Buttons:=vbExclamation + vbOKOnly, _
                        Title:="Closing...")
            Call .Close(SaveChanges:=False)
        End If
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,131
Messages
6,129,066
Members
449,485
Latest member
greggy

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
Back
Top