Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Karina K patni   on Nov 07 In MS Office Category.

  
Question Answered By: Sophie Campbell   on Nov 07

If it is controlling the closing of the userform, using the X button, you can
put this code in the userform  module:

Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the OK button."
End If
End Sub

If you are talking about using a command button  on the userform, you need
something like this in the userform module:

Private Sub CommandButton1_Click()
'CommandButton1 is the name assigned to your userform control button.
'Your macro code goes here.
End Sub

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Close operation in VBA Or get search suggestion and latest updates.


Tagged: