Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Confirm a choice before Macro
I have a macro attached to a button that will clear all data on a page. I'd
like there to be a confirmation (that's how I know it from javascript) to preceed the macro. Here's the code thus far: Sub clearAll() Range("D3,...M48").ClearContents End Sub Is there something I can throw in the macro, before the Range line that will ask, "Are you sure you want to delete all data?" If yes then fire macro, if no then end. Thanks, JSnow |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Confirm a choice before Macro
Option Explicit
Sub clearAll() Dim Resp as long resp = msgbox(Prompt:="Are you sure???",buttons:=vbyesno) if resp = vbyes then activesheet.Range("D3,...M48").ClearContents end if End Sub JSnow wrote: I have a macro attached to a button that will clear all data on a page. I'd like there to be a confirmation (that's how I know it from javascript) to preceed the macro. Here's the code thus far: Sub clearAll() Range("D3,...M48").ClearContents End Sub Is there something I can throw in the macro, before the Range line that will ask, "Are you sure you want to delete all data?" If yes then fire macro, if no then end. Thanks, JSnow -- Dave Peterson |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Confirm a choice before Macro
try this,
Sub clearAll() response = MsgBox("Are you sure you want to delete all data?", vbOKCancel) If response = vbCancel Then Exit Sub Range("D3:M48").ClearContents End Sub Mike "JSnow" wrote: I have a macro attached to a button that will clear all data on a page. I'd like there to be a confirmation (that's how I know it from javascript) to preceed the macro. Here's the code thus far: Sub clearAll() Range("D3,...M48").ClearContents End Sub Is there something I can throw in the macro, before the Range line that will ask, "Are you sure you want to delete all data?" If yes then fire macro, if no then end. Thanks, JSnow |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Confirm a choice before Macro
You guys are the best! If you're even in Ann Arbor...I owe you some beer.
"Dave Peterson" wrote: Option Explicit Sub clearAll() Dim Resp as long resp = msgbox(Prompt:="Are you sure???",buttons:=vbyesno) if resp = vbyes then activesheet.Range("D3,...M48").ClearContents end if End Sub JSnow wrote: I have a macro attached to a button that will clear all data on a page. I'd like there to be a confirmation (that's how I know it from javascript) to preceed the macro. Here's the code thus far: Sub clearAll() Range("D3,...M48").ClearContents End Sub Is there something I can throw in the macro, before the Range line that will ask, "Are you sure you want to delete all data?" If yes then fire macro, if no then end. Thanks, JSnow -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to confirm the open dialogue box by using macro coding? | Excel Worksheet Functions | |||
Macro to run when validation choice selected | Excel Discussion (Misc queries) | |||
Start Macro after user selects a choice from a pick list | Excel Discussion (Misc queries) | |||
Confirm before deleting a worksheet? | Excel Discussion (Misc queries) | |||
Confirm target cell is equal | Excel Discussion (Misc queries) |