If userform is already open then MSG box to open saying Userform in Use

Patriot2879

Well-known Member
Hi I am trying to put a code together into a command button which opens the userform1, but if someone else has the userform open already I want a msgbox pop up to say that ‘userform is in use’, I have put the following code togetherbut getting no joy. Hope you can help?

Code:
Private Sub CommandButton1_Click()
ThisWorkbook.Save
UserForm1.Show
If CurrentProject.AllForms("UserForm1").IsLoaded = False Then
     ' Form is closed
Else
     MsgBox "userform is in use"
     ' Form is open
End If

End Sub
 
Last edited:

RoryA

MrExcel MVP, Moderator
What do you mean by "if someone else has the userform open already"? Userform instances are specific to the excel application instance, so someone else can't have the same userform open.
 

RoryA

MrExcel MVP, Moderator
Not directly. You'd need to log the fact the userform is open in say a text file in a location accessible to both users (eg a network folder) and then check for that file in the form's Initialize event.
 

Patriot2879

Well-known Member
wow that sounds tricky, is there a way to share the workbook (userform) so all users can update at the same time?
 

Some videos you may like

This Week's Hot Topics

Top