If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > What is the code to prompt user before action is taken

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-23-09, 12:50
Bud Bud is offline
Registered User
 
Join Date: Dec 2003
Location: Dallas, TX
Posts: 995
Talking What is the code to prompt user before action is taken

Good afternoon,

I have a small bit that I need help with. I am using Excel 2003 and have a small bit of code to Clear out all of my entries on my sheet for me and it works well. However, I would like to actually Prompt the user as to whether or not they are wanting to perform that action BEFORE they wipe out the data on the sheet. Here is what I have to clear it, but not sure how to prompt them and where to place it.

Code:
Sub Clear()
'
' 8-25-05 by "Bud" to clear all contents
' for new input.
'
' Keyboard Shortcut: Ctrl+c
'
    Range("A2:Q65").Select
    Selection.ClearContents
    Range("A3").Select
End Sub
Thanks very much and have a nice one,
Bud
Reply With Quote
  #2 (permalink)  
Old 02-23-09, 13:35
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Code:
If MsgBox("Are you sure?", vbOKCancel, "Question?") = vbOK Then
    Range("A2:Q65").Select
    Selection.ClearContents
    Range("A3").Select
End If
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 02-25-09, 13:34
Bud Bud is offline
Registered User
 
Join Date: Dec 2003
Location: Dallas, TX
Posts: 995
Quote:
Originally Posted by gvee
Code:
If MsgBox("Are you sure?", vbOKCancel, "Question?") = vbOK Then
    Range("A2:Q65").Select
    Selection.ClearContents
    Range("A3").Select
End If
Hi George and thanks for replying. However, when I click to Clear my entries,
this is what error message I get: See the attached bitmap. Let me know if I placed it on the wrong place and where it should go.

thanks,
BUD
Attached Images
File Type: bmp ClearEntryError.bmp (756.1 KB, 26 views)
Reply With Quote
  #4 (permalink)  
Old 02-27-09, 04:42
karthic_85 karthic_85 is offline
Registered User
 
Join Date: Dec 2007
Posts: 37
u missed out END IF
__________________
Meyyappan
Reply With Quote
  #5 (permalink)  
Old 02-27-09, 05:03
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Well spotted karthic!

Bud, you should really consider tabbing out your code into blocks - it makes stuff like this much easier to spot
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On