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


I have writen a macro, but was just wondering if it is possible to add
confirmation box to popup at the start incase someone presses the butto
by mistake

--
alex198
-----------------------------------------------------------------------
alex1982's Profile: http://www.excelforum.com/member.php...fo&userid=3749
View this thread: http://www.excelforum.com/showthread.php?threadid=57171

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Confirmation box


Hi Alex,

This is one way...

Public Sub MyMacro()
Dim Check As VbMsgBoxResult
Check = MsgBox("Are you sure you want this macro to run?", vbYesNo)
If Check = vbYes Then
'Code Here
End If
End Sub

Just make sure there is no code between End If and End Sub.

Ken Johnson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Confirmation box


Where in my macro would i include this code?


--
alex1982
------------------------------------------------------------------------
alex1982's Profile: http://www.excelforum.com/member.php...o&userid=37494
View this thread: http://www.excelforum.com/showthread...hreadid=571711

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Confirmation box

Hi Alex,

Dim Check As VbMsgBoxResult
Check = MsgBox("Are you sure you want this macro to run?", vbYesNo)
If Check = vbYes Then

could be at the start of your code, then straight after the last line
of your code (but before the End Sub line) the "End If" line.

This way, your code is only run if the user clicks the "Yes" button.
When the "No" button is clicked the code jumps to the "End If" then the
End Sub, so nothing happens.

Ken Johnson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Confirmation box


Thanks, i managed to work it out. This is the first time i've really
tried to use macros for anything. :)


--
alex1982
------------------------------------------------------------------------
alex1982's Profile: http://www.excelforum.com/member.php...o&userid=37494
View this thread: http://www.excelforum.com/showthread...hreadid=571711



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Confirmation box


You're welcome Alex.
Good Luck.

Ken Johnson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Confirmation box


Here is my Before Print sub which uses a Message Box to make sure tha
the user has updated the weekly data before they print the report no
sure what your macro is doing but by changing the workbook event o
adapting the code it should be what you need or at least a step in th
right direction

Private Sub Workbook_BeforePrint(Cancel As Boolean)

Dim wk As Worksheet
Dim Config As Integer
Dim Ans As Integer

For Each wk In Worksheets
wk.Calculate
Next

Config = vbYesNo + vbQuestion + vbDefaultButton1
Ans = MsgBox("Have you updated the weekly data?", Config, "Ensur
correct data")

If Ans = vbNo Then Cancel = True

If Ans = vbYes Then Cancel = False

End Sub

Regards

Adria

--
SandyU
-----------------------------------------------------------------------
SandyUK's Profile: http://www.excelforum.com/member.php...fo&userid=1748
View this thread: http://www.excelforum.com/showthread.php?threadid=57171

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
Confirmation Security Babs in Ohio Excel Worksheet Functions 0 April 15th 09 06:20 PM
A question about the confirmation loveflying_best[_2_] Excel Discussion (Misc queries) 1 October 8th 07 12:42 PM
Getting rid of confirmation boxes DandruffKid New Users to Excel 2 March 28th 05 11:05 AM
Confirmation of file phil Excel Programming 2 January 22nd 05 02:27 AM
confirmation and close bigandyt[_2_] Excel Programming 4 July 1st 04 02:59 PM


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