VBA Code Macros

Bradley H Callender

Board Regular
Joined
Aug 5, 2010
Messages
120
How can I keep a user form up until it is used. For example i don't want the user to just close it please give me a macro code for that
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
We need more information. What does the form do? Is there a button on it that has to be pressed?
 
Upvote 0
The form just has 3 buttons

open this workbook - which would ask for user info
Workbook instructions - a list of instructtions about the workbook
close this work - which would unload the form and close excel

i want the person not to click the "x" as soon as the workbook opens i want them use the buttons.

so is there a timer or loop i can put on that "x" (close)
 
Upvote 0
Are you talking about the X on the form, or the workbook or Excel window?
 
Upvote 0
Try this code
Code:
Private Sub UserForm_QueryClose _
  (Cancel As Integer, CloseMode As Integer)
    If CloseMode = vbFormControlMenu Then
        MsgBox "Clicking the Close button does not work."
        Cancel = True
    End If
End Sub
 
Upvote 0
If you show the form modally (the default) then they have to close the userform before they can do anything.
 
Upvote 0
Walk you through what exactly? What code do you have currently to show the form?
 
Upvote 0
I only have :

Private Sub Workbook_Open()
Workbookcontrol.Show
End Sub


Thats for auto open but i want to prevent the user form using the "X" to close the whole window
 
Upvote 0

Forum statistics

Threads
1,215,051
Messages
6,122,872
Members
449,097
Latest member
dbomb1414

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