Excel VBA - Control the Close Button in the Interface| Force the User to Press Any Button

Опубликовано: 07 Октябрь 2024
на канале: The World Of Algorithms
557
like

💡 Source Code

Dim cnt As Byte
Private Sub CommandButton1_Click()
cnt = cnt + 1
If cnt = 5 Then
MsgBox "Excellent! You did what you were told!", vbOKOnly + vbInformation, ""
Unload Me
End If
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
MsgBox "You cannot close an interface with this method", vbOKOnly + vbExclamation, ""
Cancel = -1
End If
End Sub

------------------------------------------------------------------------------------------
Buy a Cofee ☕ for theworldofalgorithms: https://ko-fi.com/theworldofalgorithms

🥰Thank you for the donation. I am deeply grateful for your help!🥰
------------------------------------------------------------------------------------------

#excel
#msexcel
#msexceltutorial
#msexcelcourse
#vba
#vbatutorial
#excelvba
#fulltutorial
#excelvbatutorial
#microsoftexceltutorial
#tutorial
#exceltutorial
#advancedexcel
#advancedexceltraining
#tutor
#exceltutor
#exceltutoring
#exceltutoringonline
#onlineexceltutoring
#algorithm
#algorithms
#programming
#program
#script
#vbamacro
#vbamacros
#usingmacro
#veryuseful
#useful
#veryusefulmacro
#freeeducation
#freeprogramming
#freelancer
#excelfreelancer
#vbafreelancer
#freelanceservices
#module
#vbamodule
#closemode
#excelvbaclosemode
#vbformcontrolmenu
#cancel