Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 54
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 54
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to confirm the open dialogue box by using macro coding? Eric Excel Worksheet Functions 3 June 13th 07 12:54 PM
Macro to run when validation choice selected JDay01 Excel Discussion (Misc queries) 3 December 20th 06 08:21 PM
Start Macro after user selects a choice from a pick list mathew Excel Discussion (Misc queries) 2 August 17th 06 03:28 PM
Confirm before deleting a worksheet? edeil Excel Discussion (Misc queries) 1 January 28th 06 02:44 AM
Confirm target cell is equal Pat Excel Discussion (Misc queries) 2 December 8th 04 09:35 PM


All times are GMT +1. The time now is 07:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"