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)
What are you implementing that errors?
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"
Thanks for your interestMsgBox "Search G-25 6/NAP04 Not Found. Would you like to Continue Anyway?", 1, 48, "Search Not Found"
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
Excellent, thank you very much!![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks