+ Reply to Thread
Results 1 to 13 of 13

Warning Message needed prior to clearing spreadsheet

  1. #1
    Registered User
    Join Date
    06-07-2012
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2007
    Posts
    13

    Warning Message needed prior to clearing spreadsheet

    Hi Everyone!

    I have been asked to modify an existing macro in a workbook and I'm not sure where to start with the request. The main sheet has a macro that is attached a button that starts the macro running. It's a simple macro that when the button is pushed it start clearing cells as needed. I'd like to add a warning message prior to any clearing of cells that ask, "Are you sure you want to clear cells?". The person would need to answer with a Yes/ No application, "Yes" to continue or "No" to end the macro from running. Any help would be greatly appricated. Thanks in advance!!

    JRTDCG

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Excel 2016
    Posts
    10,178

    Re: Warning Message needed prior to clearing spreadsheet

    See if you can work with this...

    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    06-07-2012
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Warning Message needed prior to clearing spreadsheet

    Hi Jeff!!
    Worked perfect...Thank you so much for the quick reply and answer to my question.
    Best Regards- J.R.

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Excel 2016
    Posts
    10,178

    Re: Warning Message needed prior to clearing spreadsheet

    You are very welcome. Thanks for the feedback.

  5. #5
    Registered User
    Join Date
    06-21-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Warning Message needed prior to clearing spreadsheet

    hi jeffrey,

    I am in learning stage of macro. if you don't mind, can you pls tel me y we have to use second line for buttons, Y it is not allowing me to write 1 line itself. Thanks in advance

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Excel 2016
    Posts
    10,178

    Re: Warning Message needed prior to clearing spreadsheet

    Quote Originally Posted by theprincesunil View Post
    hi jeffrey,
    I am in learning stage of macro. if you don't mind, can you pls tel me y we have to use second line for buttons, Y it is not allowing me to write 1 line itself. Thanks in advance
    Hard to give an answer without seeing your example, but if you have a question you can open a new thread and get an answer there.

  7. #7
    Registered User
    Join Date
    06-21-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Warning Message needed prior to clearing spreadsheet

    ooops, sorry. I will rephrase it. In the below code what u have given, After underscore u have taken second line. when I try to write same on my Excel it throws a error. Bcs I write it on single line. Hope, I am clear now. As I have seen the above code & got the doubt. I just raised here. If u wanna me to create new thread. I will do. Pls tell me
    Please Login or Register  to view this content.

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Excel 2016
    Posts
    10,178

    Re: Warning Message needed prior to clearing spreadsheet

    Notice the _ , this is a line continuation mark.

    In the sample below, the line continuation mark is just used to wrap some of the line to the next line, but you can go without it.

    Please Login or Register  to view this content.
    Without it looks like this...

    Please Login or Register  to view this content.
    When using example 1 or example 2, you basically shave off the need for the end if.

    With using End If

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-21-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Warning Message needed prior to clearing spreadsheet

    Super Jeff. I loved ur explanation. Thanks a lot

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Excel 2016
    Posts
    10,178

    Re: Warning Message needed prior to clearing spreadsheet

    You are very welcome.

  11. #11
    Registered User
    Join Date
    06-07-2012
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Warning Message needed prior to clearing spreadsheet

    Hi Jeff!
    I know I marked the thread solved, but I have one final question. If wanted to wrap the text in the warning message, what modification would I need to make? Example being:

    WARNING!!
    Did you want to clear cells??
    Did you save your work with a new file name?
    Clearing Data will clear all cells!

    Thanks in advance!!
    J.R.

  12. #12
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Excel 2016
    Posts
    10,178

    Re: Warning Message needed prior to clearing spreadsheet

    Here is one way...

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    06-07-2012
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Warning Message needed prior to clearing spreadsheet

    Thanks Jeff!
    Your suggestion work correctly. Thanks again for all of your help with this small project.
    Regards- J.R.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1