+ Reply to Thread
Results 1 to 3 of 3

Thread: MSbox query RE VBOkCancel

  1. #1
    Registered User
    Join Date
    01-17-2011
    Location
    Kent
    MS-Off Ver
    Excel 2007
    Posts
    34

    MSbox query RE VBOkCancel

    Hello,

    this may sem like a relatively simple question. hoepfully it is!

    i have a text box linked to a cell, and when the text box loses focus, i have a message appear for confirmation. if the user selects 'cancel' i want to text box to clear out. any suggestions?

    Private Sub TextBox1_Change()
    Range("A1") = TextBox1.Value
    
    End Sub
    
    
    Private Sub TextBox1_LostFocus()
    
    MsgBox "Is this correct?", vbOKCancel, "Confirmation"
    
    End Sub
    Last edited by AppSupportKarl; 05-19-2011 at 08:16 AM.

  2. #2
    Valued Forum Contributor mohd9876's Avatar
    Join Date
    05-04-2011
    Location
    Amman, Jordan
    MS-Off Ver
    Excel 2010
    Posts
    409

    Re: MSbox query RE VBOkCancel

    try this:

    [code]
    Private Sub TextBox1_LostFocus()
    Dim Answer
    Answer = MsgBox ("Is this correct?", vbOKCancel, "Confirmation")
    If Answer = vbCancel then
    TextBox1.Value = ""
    end if

    End Sub

  3. #3
    Registered User
    Join Date
    01-17-2011
    Location
    Kent
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: MSbox query RE VBOkCancel

    Works perfectly, thanks very much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0