#1   Report Post  
bbc1
 
Posts: n/a
Default Message popup

Have a button on worksheet that clears certain cells on the sheet, would like
that a message box pops up when pressed asking user for confirmation, have
added below to the script on button but it clears cells regardless wether you
say O/k or cancel need reposne to O/k "clears cells" or cancel " does not
clear cells"
Dim response As Long
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub
  #2   Report Post  
Bryan Hessey
 
Posts: n/a
Default


try extracting from:

Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
End If

that should help

bbc1 Wrote:
Have a button on worksheet that clears certain cells on the sheet, would
like
that a message box pops up when pressed asking user for confirmation,
have
added below to the script on button but it clears cells regardless
wether you
say O/k or cancel need reposne to O/k "clears cells" or cancel " does
not
clear cells"
Dim response As Long
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub



--
Bryan Hessey
------------------------------------------------------------------------
Bryan Hessey's Profile: http://www.excelforum.com/member.php...o&userid=21059
View this thread: http://www.excelforum.com/showthread...hreadid=395724

  #3   Report Post  
bbc1
 
Posts: n/a
Default

This is what my script looks like now and it still deletes all data if cancel
is pushed
Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
End If

'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub

"Bryan Hessey" wrote:


try extracting from:

Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
End If

that should help

bbc1 Wrote:
Have a button on worksheet that clears certain cells on the sheet, would
like
that a message box pops up when pressed asking user for confirmation,
have
added below to the script on button but it clears cells regardless
wether you
say O/k or cancel need reposne to O/k "clears cells" or cancel " does
not
clear cells"
Dim response As Long
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub



--
Bryan Hessey
------------------------------------------------------------------------
Bryan Hessey's Profile: http://www.excelforum.com/member.php...o&userid=21059
View this thread: http://www.excelforum.com/showthread...hreadid=395724


  #4   Report Post  
Bryan Hessey
 
Posts: n/a
Default


Ahha, yes, my mistake, I should have been more clear, but I preferred to
show how it worked for me (with copy - paste) rather than type in here
as I type so badly.

You need

Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End if
End Sub



bbc1 Wrote:
This is what my script looks like now and it still deletes all data if
cancel
is pushed
Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
End If

'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub

"Bryan Hessey" wrote:


try extracting from:

Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
End If

that should help

bbc1 Wrote:
Have a button on worksheet that clears certain cells on the sheet,

would
like
that a message box pops up when pressed asking user for

confirmation,
have
added below to the script on button but it clears cells regardless
wether you
say O/k or cancel need reposne to O/k "clears cells" or cancel "

does
not
clear cells"
Dim response As Long
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub



--
Bryan Hessey

------------------------------------------------------------------------
Bryan Hessey's Profile:

http://www.excelforum.com/member.php...o&userid=21059
View this thread:

http://www.excelforum.com/showthread...hreadid=395724




--
Bryan Hessey
------------------------------------------------------------------------
Bryan Hessey's Profile: http://www.excelforum.com/member.php...o&userid=21059
View this thread: http://www.excelforum.com/showthread...hreadid=395724

  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default

Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < vbOK Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").ClearC ontents
Range("A2").Select
End If

End Sub

Is that what you want?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"bbc1" wrote in message
...
This is what my script looks like now and it still deletes all data if

cancel
is pushed
Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
End If

'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub

"Bryan Hessey" wrote:


try extracting from:

Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
End If

that should help

bbc1 Wrote:
Have a button on worksheet that clears certain cells on the sheet,

would
like
that a message box pops up when pressed asking user for confirmation,
have
added below to the script on button but it clears cells regardless
wether you
say O/k or cancel need reposne to O/k "clears cells" or cancel " does
not
clear cells"
Dim response As Long
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub



--
Bryan Hessey
------------------------------------------------------------------------
Bryan Hessey's Profile:

http://www.excelforum.com/member.php...o&userid=21059
View this thread:

http://www.excelforum.com/showthread...hreadid=395724






  #6   Report Post  
Bryan Hessey
 
Posts: n/a
Default


NO Bob, he does not need the code
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
'
as that was a part of how I used the OK/Cancel.

My post (timed 54 minutes before your reply) explained this,

bbc1 needs

Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End if
End Sub



Bob Phillips Wrote:
Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < vbOK Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").ClearC ontents
Range("A2").Select
End If

End Sub

Is that what you want?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"bbc1" wrote in message
...
This is what my script looks like now and it still deletes all data

if
cancel
is pushed
Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
End If

'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub

"Bryan Hessey" wrote:


try extracting from:

Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
End If

that should help

bbc1 Wrote:
Have a button on worksheet that clears certain cells on the

sheet,
would
like
that a message box pops up when pressed asking user for

confirmation,
have
added below to the script on button but it clears cells

regardless
wether you
say O/k or cancel need reposne to O/k "clears cells" or cancel "

does
not
clear cells"
Dim response As Long
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub


--
Bryan Hessey

------------------------------------------------------------------------
Bryan Hessey's Profile:

http://www.excelforum.com/member.php...o&userid=21059
View this thread:

http://www.excelforum.com/showthread...hreadid=395724




--
Bryan Hessey
------------------------------------------------------------------------
Bryan Hessey's Profile: http://www.excelforum.com/member.php...o&userid=21059
View this thread: http://www.excelforum.com/showthread...hreadid=395724

  #7   Report Post  
Earl Kiosterud
 
Posts: n/a
Default

If MsgBox(prompt:="Do you REALLY wanna do this?", Buttons:=vbYesNo) = vbYes
Then
' code goes here
End If


"bbc1" wrote in message
...
Have a button on worksheet that clears certain cells on the sheet, would
like
that a message box pops up when pressed asking user for confirmation, have
added below to the script on button but it clears cells regardless wether
you
say O/k or cancel need reposne to O/k "clears cells" or cancel " does not
clear cells"
Dim response As Long
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub



  #8   Report Post  
bbc1
 
Posts: n/a
Default

That works great
Thankyou.

"Bryan Hessey" wrote:


Ahha, yes, my mistake, I should have been more clear, but I preferred to
show how it worked for me (with copy - paste) rather than type in here
as I type so badly.

You need

Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End if
End Sub



bbc1 Wrote:
This is what my script looks like now and it still deletes all data if
cancel
is pushed
Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
End If

'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub

"Bryan Hessey" wrote:


try extracting from:

Dim response
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
If response < 2 Then
For i = 1 To Worksheets.Count + 3
Range("Q" & i + 10) = ""
Next
End If

that should help

bbc1 Wrote:
Have a button on worksheet that clears certain cells on the sheet,

would
like
that a message box pops up when pressed asking user for

confirmation,
have
added below to the script on button but it clears cells regardless
wether you
say O/k or cancel need reposne to O/k "clears cells" or cancel "

does
not
clear cells"
Dim response As Long
response = MsgBox(prompt:="ok or cancel", Buttons:=vbOKCancel)
'
Range("A2:A32,C2:C32,D2:D32,E2:E32,H2:H32").Select
Range("H2").Activate
Selection.ClearContents
Range("A2").Select
End Sub


--
Bryan Hessey

------------------------------------------------------------------------
Bryan Hessey's Profile:

http://www.excelforum.com/member.php...o&userid=21059
View this thread:

http://www.excelforum.com/showthread...hreadid=395724




--
Bryan Hessey
------------------------------------------------------------------------
Bryan Hessey's Profile: http://www.excelforum.com/member.php...o&userid=21059
View this thread: http://www.excelforum.com/showthread...hreadid=395724


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
Adding an error message at close of file when criteria are met Dave Excel Discussion (Misc queries) 3 August 12th 05 07:56 PM
when opening excel I receive a message that says file can't be fo. Ken Excel Discussion (Misc queries) 3 February 22nd 05 12:13 AM
changing the message in an error message The Villages DA Excel Worksheet Functions 2 February 18th 05 05:30 PM
"Why did we get here????" popup jtwspoon Excel Discussion (Misc queries) 3 February 4th 05 04:57 AM
Pivot Table not valid error message when formatting data 'button'. MDW Excel Discussion (Misc queries) 0 January 27th 05 03:01 PM


All times are GMT +1. The time now is 06:12 PM.

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"