Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default Putting a form into a macro string

I have created a macro in excel that clears all input data and assigned it to
a button. I need to put in a pop-up form that asks "Are you Sure" (yes/no).
Yes continues the macro; No puts you back into the spreadsheet.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Putting a form into a macro string

Try this:
Confirm = MsgBox("Are you sure?", vbQuestion + vbYesNo, "Confirm Delete")
If Confirm = Yes Then
Application.Run (Macro)
Else: Exit Sub
End If

You can use either Exit Sub or End. The vbQuestion for the buttons syntax
adds a question mark icon to the left of the text in the message box ("Are
you sure?"). The beauty of using vbYesNo is that the user cannot close the
box without answering it. Just copy and paste the above code after your
procedure name. Hope that helps!
--
Please rate posts so we know when we have answered your questions. Thanks.


"scott" wrote:

I have created a macro in excel that clears all input data and assigned it to
a button. I need to put in a pop-up form that asks "Are you Sure" (yes/no).
Yes continues the macro; No puts you back into the spreadsheet.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default Putting a form into a macro string

Thanks for the info. It's almost there. The MsgBox pops up. No works
correctly, however when I select Yes nothing happens. How do I get it to
step back into the macro.

"Orion Cochrane" wrote:

Try this:
Confirm = MsgBox("Are you sure?", vbQuestion + vbYesNo, "Confirm Delete")
If Confirm = Yes Then
Application.Run (Macro)
Else: Exit Sub
End If

You can use either Exit Sub or End. The vbQuestion for the buttons syntax
adds a question mark icon to the left of the text in the message box ("Are
you sure?"). The beauty of using vbYesNo is that the user cannot close the
box without answering it. Just copy and paste the above code after your
procedure name. Hope that helps!
--
Please rate posts so we know when we have answered your questions. Thanks.


"scott" wrote:

I have created a macro in excel that clears all input data and assigned it to
a button. I need to put in a pop-up form that asks "Are you Sure" (yes/no).
Yes continues the macro; No puts you back into the spreadsheet.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Putting a form into a macro string

Sub test()
With Selection
If MsgBox(prompt:= _
"Are you sure you want to do this", _
Buttons:=vbYesNo) = vbNo Then End
..ClearContents
End With
End Sub


Gord Dibben MS Excel MVP

On Tue, 26 Aug 2008 12:18:02 -0700, scott
wrote:

I have created a macro in excel that clears all input data and assigned it to
a button. I need to put in a pop-up form that asks "Are you Sure" (yes/no).
Yes continues the macro; No puts you back into the spreadsheet.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Putting a form into a macro string

Or you could just ask the question at the top of your existing routine:

Option Explicit
Sub YourSubNameHere()

'your declaration statements
dim Resp as long 'added

resp = msgbox(Prompt:="Are you sure?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

'your real code here
End Sub



scott wrote:

I have created a macro in excel that clears all input data and assigned it to
a button. I need to put in a pop-up form that asks "Are you Sure" (yes/no).
Yes continues the macro; No puts you back into the spreadsheet.


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Putting a form into a macro string

That's what I said. Did you put the code at the beginning of your macro?
--
Please rate posts so we know when we have answered your questions. Thanks.


"Dave Peterson" wrote:

Or you could just ask the question at the top of your existing routine:

Option Explicit
Sub YourSubNameHere()

'your declaration statements
dim Resp as long 'added

resp = msgbox(Prompt:="Are you sure?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

'your real code here
End Sub



scott wrote:

I have created a macro in excel that clears all input data and assigned it to
a button. I need to put in a pop-up form that asks "Are you Sure" (yes/no).
Yes continues the macro; No puts you back into the spreadsheet.


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default Putting a form into a macro string

Yes.

Sub Clear_Data()
'
' Clear_Data Macro
' Macro recorded 8/25/2008 by Scott D Webster
'

'
Confirm = MsgBox("Are you sure?", vbQuestion + vbYesNo, "Confirm Delete")
If Confirm = Yes Then
Application.Run (Macro)
Else: Exit Sub
End If


Sheets("1").Select
Range("A4:H42").Select

"Orion Cochrane" wrote:

That's what I said. Did you put the code at the beginning of your macro?
--
Please rate posts so we know when we have answered your questions. Thanks.


"Dave Peterson" wrote:

Or you could just ask the question at the top of your existing routine:

Option Explicit
Sub YourSubNameHere()

'your declaration statements
dim Resp as long 'added

resp = msgbox(Prompt:="Are you sure?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

'your real code here
End Sub



scott wrote:

I have created a macro in excel that clears all input data and assigned it to
a button. I need to put in a pop-up form that asks "Are you Sure" (yes/no).
Yes continues the macro; No puts you back into the spreadsheet.


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Putting a form into a macro string

Option Explicit
Sub YourSubNameHere()

'your declaration statements
dim Resp as long 'added

resp = msgbox(Prompt:="Are you sure?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

worksheets("1").range("A4:H42").clearcontents

End Sub

scott wrote:

Yes.

Sub Clear_Data()
'
' Clear_Data Macro
' Macro recorded 8/25/2008 by Scott D Webster
'

'
Confirm = MsgBox("Are you sure?", vbQuestion + vbYesNo, "Confirm Delete")
If Confirm = Yes Then
Application.Run (Macro)
Else: Exit Sub
End If

Sheets("1").Select
Range("A4:H42").Select

"Orion Cochrane" wrote:

That's what I said. Did you put the code at the beginning of your macro?
--
Please rate posts so we know when we have answered your questions. Thanks.


"Dave Peterson" wrote:

Or you could just ask the question at the top of your existing routine:

Option Explicit
Sub YourSubNameHere()

'your declaration statements
dim Resp as long 'added

resp = msgbox(Prompt:="Are you sure?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

'your real code here
End Sub



scott wrote:

I have created a macro in excel that clears all input data and assigned it to
a button. I need to put in a pop-up form that asks "Are you Sure" (yes/no).
Yes continues the macro; No puts you back into the spreadsheet.

--

Dave Peterson


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Putting a form into a macro string

I was answering the original post--not responding to your message.

Your message wasn't there when I retrieved the headers, so I answered the
question.

Orion Cochrane wrote:

That's what I said. Did you put the code at the beginning of your macro?
--
Please rate posts so we know when we have answered your questions. Thanks.

"Dave Peterson" wrote:

Or you could just ask the question at the top of your existing routine:

Option Explicit
Sub YourSubNameHere()

'your declaration statements
dim Resp as long 'added

resp = msgbox(Prompt:="Are you sure?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

'your real code here
End Sub



scott wrote:

I have created a macro in excel that clears all input data and assigned it to
a button. I need to put in a pop-up form that asks "Are you Sure" (yes/no).
Yes continues the macro; No puts you back into the spreadsheet.


--

Dave Peterson


--

Dave Peterson
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Putting a form into a macro string

And my code didn't call another subroutine. So there was a difference.

Orion Cochrane wrote:

That's what I said. Did you put the code at the beginning of your macro?
--
Please rate posts so we know when we have answered your questions. Thanks.

"Dave Peterson" wrote:

Or you could just ask the question at the top of your existing routine:

Option Explicit
Sub YourSubNameHere()

'your declaration statements
dim Resp as long 'added

resp = msgbox(Prompt:="Are you sure?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

'your real code here
End Sub



scott wrote:

I have created a macro in excel that clears all input data and assigned it to
a button. I need to put in a pop-up form that asks "Are you Sure" (yes/no).
Yes continues the macro; No puts you back into the spreadsheet.


--

Dave Peterson


--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Putting a form into a macro string

Actually, I did see your reply. I just didn't see the reason to call the other
routine.

Orion Cochrane wrote:

That's what I said. Did you put the code at the beginning of your macro?
--
Please rate posts so we know when we have answered your questions. Thanks.

"Dave Peterson" wrote:

Or you could just ask the question at the top of your existing routine:

Option Explicit
Sub YourSubNameHere()

'your declaration statements
dim Resp as long 'added

resp = msgbox(Prompt:="Are you sure?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

'your real code here
End Sub



scott wrote:

I have created a macro in excel that clears all input data and assigned it to
a button. I need to put in a pop-up form that asks "Are you Sure" (yes/no).
Yes continues the macro; No puts you back into the spreadsheet.


--

Dave Peterson


--

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
Putting together a form Chey Excel Discussion (Misc queries) 1 April 11th 07 03:50 AM
How to show User Form when form name is in string? Don Wiss Excel Programming 2 December 9th 06 03:52 AM
putting a string from one cell in the formula of another -- indirect needed? [email protected] Excel Worksheet Functions 3 January 23rd 06 07:55 PM
Putting plain text string into clipboard in VBA? Don Wiss Excel Programming 4 May 22nd 05 10:24 AM
Separate String into string + value form Johnny[_6_] Excel Programming 3 February 27th 04 02:38 PM


All times are GMT +1. The time now is 10:13 AM.

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

About Us

"It's about Microsoft Excel"