Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Message box\Forms button

I have created a button for the FORMS toolbar that has a macro that deletes
data from a page to reset it. I would like to have a message come up when
the button is pressed asking if they really want to erase the data. If they
press YES, then I want the macro to run, If they press NO, then I just wan
the message box to close and go back to the spreadsheet.

I am stumped on this...Please help

Jase
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Message box\Forms button


Use this for your command button click:

Private Sub CommandButton1_Click()
Dim msg
msg = MsgBox("Do you really want to erase the data?", vbYesNo, "Warning
Data Deletion")
If msg = vbYes Then
MsgBox "You can run your code here as YES was clicked"
'Your code
Unload Me
ElseIf msg = vbNo Then
MsgBox "You can run your code or exit the sub here as NO was clicked"
Unload Me
End If
End Sub

Jase4now;324101 Wrote:
I have created a button for the FORMS toolbar that has a macro that
deletes
data from a page to reset it. I would like to have a message come up
when
the button is pressed asking if they really want to erase the data. If
they
press YES, then I want the macro to run, If they press NO, then I just
wan
the message box to close and go back to the spreadsheet.

I am stumped on this...Please help

Jase



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=90562

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Message box\Forms button

Option Explicit
Sub YourMacroNameHere()
dim Resp as long

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

if resp = vbno then
exit sub
end if

'rest of your code

End Sub


Jase4now wrote:

I have created a button for the FORMS toolbar that has a macro that deletes
data from a page to reset it. I would like to have a message come up when
the button is pressed asking if they really want to erase the data. If they
press YES, then I want the macro to run, If they press NO, then I just wan
the message box to close and go back to the spreadsheet.

I am stumped on this...Please help

Jase


--

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
Replace microsoft forms message box with something more meaningful Forum Freak[_2_] Excel Programming 4 July 24th 08 08:50 PM
Disabling a forms 1.0 button Will Finkle Excel Programming 5 September 30th 07 08:10 AM
Run Hyperlink by forms button Corey Excel Programming 2 September 4th 07 04:11 AM
Forms - Error Message for Non-Entry of Data morrisli Excel Discussion (Misc queries) 0 February 7th 07 09:36 AM
hiding forms button bigtonyicu Excel Discussion (Misc queries) 1 August 11th 05 11:00 PM


All times are GMT +1. The time now is 08:42 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"