How to Add a Yes No Pop-up Message Box to a Macro Before it Runs (Part 4 of 4)
Вставка
- Опубліковано 6 сер 2024
- Sign up for our Excel webinar, times added weekly: www.excelcampus.com/blueprint...
Learn how to make a Yes No Message Box (pop-up window) appear before the macro code runs. This is critical if you have custom macro buttons on the ribbon or anywhere in your workbook.
If the user accidentally presses a macro button then the code will run and could potentially ruin the workbook or cause irreversible damage.
The Yes No Message Box is easy to implement in any macro and only requires four lines of code.
Read the article and download the Excel file here:
www.excelcampus.com/vba/person...
In this video I explain exactly how to create this code and how to use the msgbox function in VBA.
The msgbox function is basically a line of code that creates a pop-up window with buttons on it. This means you do NOT need to create a userform. The function has parameters that allow you to choose what the buttons will say. It could be Yes/No, Ok/Cancel, Ok Only, Warning icon, or many other options. This is a great VBA skill to learn and add to any macro.
Other videos in this series:
How to Create a Personal Macro Workbook in Excel and Why You Need It (Part 1 of 4):
• How to Create a Person...
Where Is The Personal Macro Workbook Stored and How to View It (Part 2 of 4):
• Where Is The Personal ...
How to Add Macro Buttons to the Excel Ribbon or Quick Access Toolbar (Part 3 of 4):
• How to Add Macro Butto...
Please leave a comment below with any questions, and don't forget to hit the LIKE button if you enjoyed this video. Thank you!!!
00:00 Introduction
00:21 What is a Yes No Message Box
01:21 VBA Editor
01:48 Macro Code
02:20 Message Box Variable
04:48 If Statement
06:50 Running the Macro
08:40 Conclusion - Навчання та стиль
You make it soo easy! I have been hesitant to learn macros because I thought it would be so challenging, but you make it so easy. I'm a 'why does it do that' person and need to know all the parts and you explained it all. Thank you!
You're so welcome, Kelly ! 😀
I am the same way. I like to know how everything works so I know what my importance is.
Thanks for the well made and informative and useful 4 part series!
Jon, you are amazing. You make all your trainings so easy to understand. Thank you!!!
This information is very informative and useful. The four part series was great. You explain it so simple that anyone can do it. Thank you
Excellent class ! Your advice is so important and helpful. Thank you so much~ hope to follow all your courses
It was indeed helpful and enjoyable at the same time, great thanks man!
Excellent 4-part tutorial! Thanks for sharing!
Hi John, Your vedios on Macro helped me lot , I liked your style of explaining every thing in very easy, short and understandable way. Good luck to you and keep it up.
Glad you like them! 😀
Thank you Jon. This is a big help.
Thanks this was an excellent series and #4 was GREAT!
Extremely useful macro tutorial series. Thanks a lot :-)
Thanks a lot, this is a great macro and very helpful. Just implemented and it works.
Thank you Jon, for this informative videos.
Very informative. Excellent! Thanks Jon, keep up!
Nice, thanks! Please show us how to change Pivot Table Filter Reports Tabs in different colors or by VBA Code and then add them to our Tool Belt. Thanks
Fantastic video for beginners, thanks!!
thank you very much for the tutorial.that was awesome videos and easy access to all personnel micro
Thanks! You're a legend. Unfortunately I found this video AFTER I accidentally clicked a 'delete results' macro I created and assigned to a button... do'h. At least now it won't happen again ;-)
Thanks from Scotland, John.
Thanks Jon, very good/useful...
Great topic and training session
This is exactly what I needed.
thanks so much ......very much helpful info
Very informative. Thanks.
Thank you, very clear very easy!!!
Truly very helful . Thank you a lot
Thanks for the great info
Thanks, it is simple to follow and use
Great Video
Wonderful video sir
Thank you jon! I've been trying to find a tutorial that just continues on the pressing of no but all these dorky kids with the other videos would only show how to make silly messages on the clicking of no and this is not very professional with my college project
Thank you Jon. I wonder if there's a way to display an image containing math formulas or math symbols such as "Square root" in a message box ?
Thank you - Great help! Can the message box (and the macro) be "Would you like to ACCEPT the result of the macro? This way it could be even more safer with such a message box.
Thanks for the great video. I've watched all 4 and they are great. When I open a new workbook, I can't run the functions that I have saved in my PERSONAL.XLSB unless I drag the module to the current workbook macros. Is this normal or have I missed something? If this is normal is there a way around this so I can use all my coded functions as soon as a new workbook opens without dragging modules?
Thanks Jon.. this would really helpful..
Thanks for sharing..
Glad it was helpful! 😀
Excellent!!
Hey Jon, that was a great video, thanks. So I got into VBA a few years back and designed a user form to keep inventory with bar codes. This time around I have designed this VBA user form to do quality checks for tech equipment. Some of the techs that will be using this have asked if they can skip out of the user form and just enter the work sheet to add the columns they are working on. This seems like a solution that may just work. Will this work for activating F5 to start the user forms and not start if the answer is no?
I’m new to excel. I appreciate your videos. I have copied my personal vbs file and exported my ui file. Is there a video that shows how to import those files on another computer?
Very useful.. Teacher
Thank you :)
Thanks Jon
Hello Jon, very helpful video.
I want to know that can we make any macro or popup massage who reply us that how many updates have been changed.
For example - when we find any word and replace with some other word mannually the excel shows a pop-up massage that "10 changes made". Can we apply this in a macro.
I hope you understand my query.
Hi Jon, you've been fantastic! thank you so much! I'm a VBA beginner and I tried to run a module written on the first file on a new workbook and for some reason part of the module ran on the first workbook, is it because certanin commands are workbook specific? many thanks!
Thankyou
Very helpful, I have been running macros for so long, I run some of them by mistake and ruined some of my work jajaja
Thanks.
I'm trying to share the macro I created with my team. How can I save it so all they need to do is enable an add-in? Thanks in advance!
Why you didn't code an "exit" to not execute the macro inmediatelly if the answer is "not"?
Could it be possible to create an extenal routine called "test_execution" and there just prompt for the "yes" or "not" and abort all the execution accordingly? So, I could call to "test_execution" at the beginning of all my macros.
hi john please tell me how to creat add-ins? I am waiting your reply thanks
Hi, Thanks for sharing this. I used this vba query in my excel macro file. But im getting an error message like "Compile Error : Expected End With"
This macro was working fine when I first typed it, and then it stopped to work. I've discovered that accidentally I've changed the vbYes into bvYes which has no meaning in the syntax . So, I fixed that typo. and it should work fine
Hello Jon
Thank you for this amazing series, I have one question! How did you align your 3 lines text code by one click ?
(In 5:44)
Thank u in advance
Select the three lines and press Tab.
Jon, you are linking a macro from the workbook "PERSONAL.XLSB" to your Excel ribbon. This means that if the workbook "PERSONAL.XLSB" is not open, excel will open this workbook to find the macro. Are we able to add an error check to state that if the original workbook is not open then do not run the macro? I can't seem to find a solution to this issue, so any suggestions would be appreciated.
oh followed. checked all data and i get the prompt yet it does not run the macro (i dont get my extra sheets) on chosing yes HMM
If any cell change the popup will appear like vbyesNo once select yes then the result yes fill in specific cell same no answer pls guide code
How do you add the macro tab on the ribbon for Mac? I can't do it the way you explained.
Hi Melissa, I don't believe you can customize the ribbon to add macros buttons on the 2016 version of Excel yet. You can use an add-in file and write XML code to customize the ribbon. Here is a forum post that explains more. answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_mac/assign-macro-to-ribbon-button/cb37f050-d1b4-4cd3-be69-d2262e9ba213
Hi Jon,
I did open a Personal Macro Workbook according to your instructions.
When I run the 3-Sheet-Macro, it always opens a new Worksheet called PERSONAL, although there is no coding stating that in the macro? The command as such is only executed in this PERSONAL Worksheet even if I am working on another Worksheet. How come?
I tried to type Dim Answer~~~~ but only question marks came out. I don't know why 😢😢
Sir how can i print a hidden sheet.
I just came here to learn how to mess with my friends making annoying msgboxes
How to add msg pop up to a code after its macro Run..??? you have done for before its macro run
Here is a test for Jon to see if he reads these comments and how quickly he responds. I am writing this on 14 Dec 2022 at 19:58 UK time. Over to you Jon
Hello Zia! 😀