+ Reply to Thread
Results 1 to 5 of 5

Thread: Message Box Prompt. Continue Or Cancel

  1. #1
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    71

    Message Box Prompt. Continue Or Cancel

    Hey Everyone,

    I'm using the find function in excel VB. I want to display a message box prompt if the text I'm searching isn't found. One that allows the user to continue running the code or cancel. But each time I try to implement a box I get errors. How could I go about doing this? Here is an example of my search function.


    Thanks for your help everyone

    Dim FieldTotalEst As Range
        Set FieldTotalEst = Worksheets("Daily Report").Cells.Find(What:="Field Total Est.", LookIn:=xlFormulas, LookAt:=xlWhole, _
                           SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, _
                           SearchFormat:=False)

  2. #2
    Forum Guru Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    MS Excel 2010
    Posts
    2,247

    Re: Message Box Prompt. Continue Or Cancel

    What are you implementing that errors?

  3. #3
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Message Box Prompt. Continue Or Cancel

    There's kind of two issues, I don't know how to implement code that says " hey! the search didn't find anything would you like to continue anyway?" and also when I try to create a message box I use the below code and get the error " Invalid Procedure call or Arguement"

    MsgBox "Search G-25 6/NAP04 Not Found. Would you like to Continue Anyway?", 1, 48, "Search Not Found"
    Thanks for your interest

  4. #4
    Forum Guru Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    MS Excel 2010
    Posts
    2,247

    Re: Message Box Prompt. Continue Or Cancel

    Dim FieldTotalEst As Range
        On Error Resume Next
        Set FieldTotalEst = Worksheets("Daily Report").Cells.Find(What:="Field Total Est.", LookIn:=xlFormulas, LookAt:=xlWhole, _
                           SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, _
                           SearchFormat:=False)
        On Error GoTo 0
        If FieldTotalEst Is Nothing Then
        
            If MsgBox("Search G-25 6/NAP04 Not Found. Would you like to Continue Anyway?", vbYesNo + vbQuestion, "Search Not Found") = vbYes Then
            
                'do your stuff
            End If
        End If

  5. #5
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Message Box Prompt. Continue Or Cancel

    Excellent, thank you 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