Need Message Box before running macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like a message box to pop up to warn the user that they are about to
clear all entries on the sheet with an option for them to back out. How do I
write that into the macro? The message would read, "You are about to clear
all entries on this sheet. Do you want to proceed?" I've never done one of
these before, but I do know a little about VBA language.
 
Hi

like this

sub checkmessage()
dim i as integer
i = msgbox("You are about to clear all entries on this sheet. Do you
want to proceed?",vbyesno+vbquestion,"Proceed?") 'make sure this all goes on
one line
if i = vbno then
exit sub
end if
'the code from your existing macro here
end sub

Hope this helps
Cheers
JulieD
 
Julie:

I wrote that into my macro, and when I pressed the button, the box popped up
perfectly and when I selected "yes", it indeed cleared all entries. However,
when I selected "no", it ALSO cleared the entries. What did I do wrong?
 
Hi

please copy & paste all of your code for this macro in your reply, for me to
have a look at.

Regards
JulieD
 
Here it is...you'll probably find something else I did wrong in the original
macro. It looks long and could probably be shortened.

Sub CLEARIT()
'
' CLEARIT Macro
' Macro recorded 10/28/2004 by Rick Sullivan
'

'Sub checkmessage()
Dim i As Integer
i = MsgBox("You are about to clear all entires on this sheet. Do you
want to proceed?", vbYesNo + vbQuestion, "Proceed?")
If i = vbNo Then
End If
Range("D7:J60,K66:L67").Select
Range("K66").Activate
ActiveWindow.ScrollRow = 35
ActiveWindow.ScrollRow = 34
ActiveWindow.ScrollRow = 33
ActiveWindow.ScrollRow = 32
ActiveWindow.ScrollRow = 31
ActiveWindow.ScrollRow = 30
ActiveWindow.ScrollRow = 29
ActiveWindow.ScrollRow = 28
ActiveWindow.ScrollRow = 27
ActiveWindow.ScrollRow = 26
ActiveWindow.ScrollRow = 25
ActiveWindow.ScrollRow = 24
ActiveWindow.ScrollRow = 23
ActiveWindow.ScrollRow = 22
ActiveWindow.ScrollRow = 21
ActiveWindow.ScrollRow = 20
ActiveWindow.ScrollRow = 19
ActiveWindow.ScrollRow = 18
ActiveWindow.ScrollRow = 17
ActiveWindow.ScrollRow = 16
ActiveWindow.ScrollRow = 15
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 13
ActiveWindow.ScrollRow = 11
ActiveWindow.ScrollRow = 10
ActiveWindow.ScrollRow = 9
ActiveWindow.ScrollRow = 8
ActiveWindow.ScrollRow = 7
ActiveWindow.ScrollRow = 6
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 1
Range("D7:J60,K66:L67,K1:M1,K2:M2,K3,M3").Select
Range("M3").Activate
Selection.ClearContents
ActiveWindow.SmallScroll Down:=-9
Range("K1:M1").Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top