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

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,036
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:

Some videos you may like

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,692
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
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.
 

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,036
Hi I would have workbook shared . And if a user is in userform then to notify the other person
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,692
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
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
Joined
Feb 1, 2018
Messages
1,036
wow that sounds tricky, is there a way to share the workbook (userform) so all users can update at the same time?
 

Watch MrExcel Video

Forum statistics

Threads
1,090,459
Messages
5,414,647
Members
403,540
Latest member
mmorejon1215

This Week's Hot Topics

Top