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