Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking Unanswered: 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

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    If MsgBox("Are you sure?", vbOKCancel, "Question?") = vbOK Then
        Range("A2:Q65").Select
        Selection.ClearContents
        Range("A3").Select
    End If
    George
    Home | Blog

  3. #3
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    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 Thumbnails Attached Thumbnails ClearEntryError.bmp  

  4. #4
    Join Date
    Dec 2007
    Posts
    37
    u missed out END IF
    Meyyappan

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Well spotted karthic!

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •