#1   Report Post  
John
 
Posts: n/a
Default Macro

I think this is doable and easy, but i can not figure it out for the life of
me.

I have a macro that clears on the information from the screen. Can you have
something in the macro, that will prompt the user to ask a question, such as,
"Are you sure you want to clear all this information" The user can then
click yes or no. I guess it is similar to a validation.

  #2   Report Post  
David Hepner
 
Posts: n/a
Default

Try this:

Sub Clear_Screen()

Dim response As Integer
Dim msg As String

msg = "Are you sure you want to clear all this information"
response = MsgBox(msg, vbYesNo, "WARNING")
If response = vbYes Then
'Enter existing code that clears the screen
Else
'Do something else
End If

End Sub




"John" wrote:

I think this is doable and easy, but i can not figure it out for the life of
me.

I have a macro that clears on the information from the screen. Can you have
something in the macro, that will prompt the user to ask a question, such as,
"Are you sure you want to clear all this information" The user can then
click yes or no. I guess it is similar to a validation.

  #3   Report Post  
Chip Pearson
 
Posts: n/a
Default

Just a very small point,

Dim response As Integer

should be

Dim response As Long
or better, in Excel 2000 or later,
Dim response As VbMsgBoxResult


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"David Hepner" wrote in
message
...
Try this:

Sub Clear_Screen()

Dim response As Integer
Dim msg As String

msg = "Are you sure you want to clear all this information"
response = MsgBox(msg, vbYesNo, "WARNING")
If response = vbYes Then
'Enter existing code that clears the screen
Else
'Do something else
End If

End Sub




"John" wrote:

I think this is doable and easy, but i can not figure it out
for the life of
me.

I have a macro that clears on the information from the screen.
Can you have
something in the macro, that will prompt the user to ask a
question, such as,
"Are you sure you want to clear all this information" The
user can then
click yes or no. I guess it is similar to a validation.



  #4   Report Post  
FSt1
 
Posts: n/a
Default

hi,
yes

msgbox("are you sure???",vbyesnow, warning)

look up msgbox in vb help (not excel help)

regards
FSt1

"John" wrote:

I think this is doable and easy, but i can not figure it out for the life of
me.

I have a macro that clears on the information from the screen. Can you have
something in the macro, that will prompt the user to ask a question, such as,
"Are you sure you want to clear all this information" The user can then
click yes or no. I guess it is similar to a validation.

  #5   Report Post  
John
 
Posts: n/a
Default

Thanks David, however
IT clears the page regardless of it i hit Yes or No.

Do i have to put the Else, way down at the end of the macro?

"David Hepner" wrote:

Try this:

Sub Clear_Screen()

Dim response As Integer
Dim msg As String

msg = "Are you sure you want to clear all this information"
response = MsgBox(msg, vbYesNo, "WARNING")
If response = vbYes Then
'Enter existing code that clears the screen
Else
'Do something else
End If

End Sub




"John" wrote:

I think this is doable and easy, but i can not figure it out for the life of
me.

I have a macro that clears on the information from the screen. Can you have
something in the macro, that will prompt the user to ask a question, such as,
"Are you sure you want to clear all this information" The user can then
click yes or no. I guess it is similar to a validation.



  #6   Report Post  
David Hepner
 
Posts: n/a
Default

John,

You must must the existing macro that clears the sheets and paste it uder
the section 'Enter existing code that clears the screen. If you have done
this and it still doesn't work. Copy your macro code and post it so I can
look at it.

"John" wrote:

Thanks David, however
IT clears the page regardless of it i hit Yes or No.

Do i have to put the Else, way down at the end of the macro?

"David Hepner" wrote:

Try this:

Sub Clear_Screen()

Dim response As Integer
Dim msg As String

msg = "Are you sure you want to clear all this information"
response = MsgBox(msg, vbYesNo, "WARNING")
If response = vbYes Then
'Enter existing code that clears the screen
Else
'Do something else
End If

End Sub




"John" wrote:

I think this is doable and easy, but i can not figure it out for the life of
me.

I have a macro that clears on the information from the screen. Can you have
something in the macro, that will prompt the user to ask a question, such as,
"Are you sure you want to clear all this information" The user can then
click yes or no. I guess it is similar to a validation.

  #7   Report Post  
David Hepner
 
Posts: n/a
Default

I cannot type or read today:

You must cut the existing macro that clears the sheets and paste it under
the section 'Enter existing code that clears the screen. If you have done
this and it still doesn't work. Copy your macro code and post it so I can
look at it.


"David Hepner" wrote:

John,

You must must the existing macro that clears the sheets and paste it uder
the section 'Enter existing code that clears the screen. If you have done
this and it still doesn't work. Copy your macro code and post it so I can
look at it.

"John" wrote:

Thanks David, however
IT clears the page regardless of it i hit Yes or No.

Do i have to put the Else, way down at the end of the macro?

"David Hepner" wrote:

Try this:

Sub Clear_Screen()

Dim response As Integer
Dim msg As String

msg = "Are you sure you want to clear all this information"
response = MsgBox(msg, vbYesNo, "WARNING")
If response = vbYes Then
'Enter existing code that clears the screen
Else
'Do something else
End If

End Sub




"John" wrote:

I think this is doable and easy, but i can not figure it out for the life of
me.

I have a macro that clears on the information from the screen. Can you have
something in the macro, that will prompt the user to ask a question, such as,
"Are you sure you want to clear all this information" The user can then
click yes or no. I guess it is similar to a validation.

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
macro with F9 Kenny Excel Discussion (Misc queries) 1 August 3rd 05 02:41 PM
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM


All times are GMT +1. The time now is 05:56 PM.

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"