+ Reply to Thread
Results 1 to 7 of 7

Clear Button Warning

  1. #1
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    221

    Clear Button Warning

    Sub ertert()
    If MsgBox("Do you really want to delete the data", 36) = vbYes Then
    Range("A1:B5").ClearContents
    End If
    End Sub

    I have a clear button linked to a macro and I do want to keep the clear button however would like to have a message to verify that the user didn't press it in error. I was provided with the above however it does not seem to work. Would anyone have a suggestion?

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Clear Button Warning

    I'm not sure what do you mean by:
    would like to have a message to verify that the user didn't press it in error
    do you want to re-confirm a confirmation?

    If so, this may help:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Clear Button Warning

    No I don't want to re-confirm I just want to confirm after the button is pressed. Maybe I was entering this wrong. Is it entered within the original macro after End Sub or exactly how is it placed?

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Clear Button Warning

    Let me understand this correctly, you press a button on your workbook, and then:
    Case1: The button directly calls ertert() procedure, or
    Case2: The button indirectly calls ertert() procedure (i.e. the botton calls some_other_procedure(), and then some_other_procedure() calls ertert()
    Case3: Something else (in which case, please explain exactly what it is).

    Regards,
    Jewel

  5. #5
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Clear Button Warning

    No it is simpler than that.

    I have a macro to clear a range of cells and have attached a button on the sheet to run the macro. That all works fine but I would just like a warning asking to verify wanting to clear the sheet incase the button is pressed in error

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Clear Button Warning

    That should be fairly straight forward. Try this:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Clear Button Warning

    do I enter this on the original macro or a new one and if on the original after end sub of the current listing in the macro?

    My current macro looks like this

    Sub Clear_Cells()
    Range("G8:N8").ClearContents
    Range("S9").ClearContents
    Range("C10:D10").ClearContents
    Range("E10:F10").ClearContents
    Range("G10:I10").ClearContents
    Range("J10:L10").ClearContents
    Range("M10:N10").ClearContents
    Range("C11:D11").ClearContents
    Range("E11:F11").ClearContents
    Range("G11:I11").ClearContents
    Range("J11:L11").ClearContents
    Range("M11:N11").ClearContents
    Range("E14").ClearContents
    Range("I14").ClearContents
    Range("M14").ClearContents
    Range("E15").ClearContents
    Range("F15").ClearContents
    Range("I15").ClearContents
    Range("J15").ClearContents
    Range("M15").ClearContents
    Range("N15").ClearContents
    Range("N9").ClearContents
    Range("E22:F22").ClearContents
    Range("I22:J22").ClearContents
    Range("M22:N22").ClearContents
    Range("E28:F28").ClearContents
    Range("I28:J28").ClearContents
    Range("M28:N28").ClearContents
    Range("E29:F29").ClearContents
    Range("I29:J29").ClearContents
    Range("M29:N29").ClearContents
    Range("D30").ClearContents
    Range("H30").ClearContents
    Range("L30").ClearContents
    End Sub
    Last edited by mikerules; 03-28-2014 at 01:28 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Clear button, add warning dialogue box that asks: Are you sure you want to clear?
    By nenadmail in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-21-2012, 02:41 PM
  2. [SOLVED] Clear Button?
    By dsklein85 in forum Excel General
    Replies: 1
    Last Post: 04-08-2012, 02:41 PM
  3. Button to clear sheet and automatic clear rows
    By sandbach in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-29-2010, 02:06 PM
  4. clear button
    By annick in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-14-2006, 06:40 AM

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