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
  • Навчання та стиль

КОМЕНТАРІ • 69

  • @kellyboyd295
    @kellyboyd295 8 місяців тому +3

    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!

    • @ExcelCampus
      @ExcelCampus  8 місяців тому +1

      You're so welcome, Kelly ! 😀

    • @randomrandy3059
      @randomrandy3059 8 місяців тому

      I am the same way. I like to know how everything works so I know what my importance is.

  • @excelisfun
    @excelisfun 8 років тому +5

    Thanks for the well made and informative and useful 4 part series!

  • @dirtylilasian
    @dirtylilasian 3 роки тому +3

    Jon, you are amazing. You make all your trainings so easy to understand. Thank you!!!

  • @lionelvelez9198
    @lionelvelez9198 8 років тому +2

    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

  • @chunyanji7742
    @chunyanji7742 3 роки тому +1

    Excellent class ! Your advice is so important and helpful. Thank you so much~ hope to follow all your courses

  • @wisomiso2348
    @wisomiso2348 8 років тому +1

    It was indeed helpful and enjoyable at the same time, great thanks man!

  • @michaelm9351
    @michaelm9351 2 місяці тому

    Excellent 4-part tutorial! Thanks for sharing!

  • @ambarishbhusari3859
    @ambarishbhusari3859 4 роки тому +1

    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.

  • @tannertucker22
    @tannertucker22 7 років тому +5

    Thank you Jon. This is a big help.

  • @DarrellWade
    @DarrellWade 8 років тому

    Thanks this was an excellent series and #4 was GREAT!

  • @alexrosen8762
    @alexrosen8762 6 років тому

    Extremely useful macro tutorial series. Thanks a lot :-)

  • @irindi1
    @irindi1 5 років тому

    Thanks a lot, this is a great macro and very helpful. Just implemented and it works.

  • @akshitaanddhruvkidsvlog3304
    @akshitaanddhruvkidsvlog3304 8 років тому +1

    Thank you Jon, for this informative videos.

  • @sohayle_p.6955
    @sohayle_p.6955 2 роки тому +1

    Very informative. Excellent! Thanks Jon, keep up!

  • @shoppersdream
    @shoppersdream 5 місяців тому

    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

  • @pete4monc
    @pete4monc 4 роки тому +1

    Fantastic video for beginners, thanks!!

  • @tajsay
    @tajsay 4 роки тому

    thank you very much for the tutorial.that was awesome videos and easy access to all personnel micro

  • @eduardocorrochio208
    @eduardocorrochio208 3 роки тому +1

    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 ;-)

  • @tonyhallett3255
    @tonyhallett3255 5 років тому

    Thanks from Scotland, John.

  • @tristanquintus3200
    @tristanquintus3200 8 років тому +1

    Thanks Jon, very good/useful...

  • @peterbarreca1568
    @peterbarreca1568 4 роки тому +1

    Great topic and training session

  • @eissacmedic
    @eissacmedic 3 роки тому +1

    This is exactly what I needed.

  • @anilthakkar2372
    @anilthakkar2372 2 роки тому +1

    thanks so much ......very much helpful info

  • @rrdangalang591
    @rrdangalang591 5 років тому +1

    Very informative. Thanks.

  • @bassamthebian9461
    @bassamthebian9461 2 роки тому +1

    Thank you, very clear very easy!!!

  • @bendaouda3236
    @bendaouda3236 6 років тому

    Truly very helful . Thank you a lot

  • @johnzschoche8872
    @johnzschoche8872 5 років тому +1

    Thanks for the great info

  • @raviparmar431
    @raviparmar431 2 роки тому

    Thanks, it is simple to follow and use

  • @yoryiyork
    @yoryiyork 3 роки тому +1

    Great Video

  • @SanviPatil2019
    @SanviPatil2019 2 роки тому +1

    Wonderful video sir

  • @geofox9484
    @geofox9484 5 років тому

    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

  • @hoanguyenthithu6572
    @hoanguyenthithu6572 4 роки тому

    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 ?

  • @larsholck
    @larsholck 4 роки тому

    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.

  • @nccar38
    @nccar38 5 років тому

    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?

  • @mohitjagad
    @mohitjagad 4 роки тому +1

    Thanks Jon.. this would really helpful..
    Thanks for sharing..

  • @grahamhawkins9026
    @grahamhawkins9026 5 років тому

    Excellent!!

  • @pcpmundo
    @pcpmundo 7 років тому

    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?

  • @kennethsalisbury6918
    @kennethsalisbury6918 6 років тому

    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?

  • @me3jab1
    @me3jab1 7 років тому

    Very useful.. Teacher

  • @empty_mirror
    @empty_mirror 4 роки тому +1

    Thank you :)

  • @jesiguenza3327
    @jesiguenza3327 4 роки тому +1

    Thanks Jon

  • @kameshsharma5164
    @kameshsharma5164 6 років тому

    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.

  • @owenlau2025
    @owenlau2025 7 місяців тому

    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!

  • @asadimran4135
    @asadimran4135 4 роки тому +1

    Thankyou

  • @nmejiai
    @nmejiai 2 роки тому

    Very helpful, I have been running macros for so long, I run some of them by mistake and ruined some of my work jajaja

  • @drajune
    @drajune 4 роки тому +1

    Thanks.

  • @ericbunker2590
    @ericbunker2590 7 років тому +1

    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!

  • @JamesManjackalMSFS
    @JamesManjackalMSFS 7 років тому

    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.

  • @imranali-iy5wk
    @imranali-iy5wk 7 років тому

    hi john please tell me how to creat add-ins? I am waiting your reply thanks

  • @vpvenky
    @vpvenky 3 роки тому

    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"

  • @fahmylina123
    @fahmylina123 7 років тому +1

    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

  • @abdanomer
    @abdanomer 6 років тому

    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

  • @nickstewart473
    @nickstewart473 6 років тому

    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.

  • @JockStrop
    @JockStrop 2 роки тому

    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

  • @mah22jadhav
    @mah22jadhav Рік тому

    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

  • @melissadaniel3937
    @melissadaniel3937 7 років тому +1

    How do you add the macro tab on the ribbon for Mac? I can't do it the way you explained.

    • @ExcelCampus
      @ExcelCampus  7 років тому

      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

  • @andreasgruber6740
    @andreasgruber6740 4 роки тому

    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?

  • @sophiakim1315
    @sophiakim1315 2 місяці тому

    I tried to type Dim Answer~~~~ but only question marks came out. I don't know why 😢😢

  • @bhaskarrao8856
    @bhaskarrao8856 4 роки тому

    Sir how can i print a hidden sheet.

  • @Lukencio0
    @Lukencio0 3 роки тому +1

    I just came here to learn how to mess with my friends making annoying msgboxes

  • @uriyadi6245
    @uriyadi6245 2 роки тому

    How to add msg pop up to a code after its macro Run..??? you have done for before its macro run

  • @ziasiddique3172
    @ziasiddique3172 Рік тому +1

    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