Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If Error
Hi.
The following code finds a text string in worksheet "Blank 1". I need to have a msgbox come-up if the text is not found. How should I program so that an error won't throw the user into the module? myRow = Worksheets("Blank 1").Rows.Find (What:=AgentName).Row + 1 Thanks, Mike. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
If Error
Try this:
On Error Resume Next 'disable error myRow = Worksheets("Blank 1").Rows.Find _ (What:=AgentName).Row + 1 If myRow 0 Then 'do something MsgBox myRow Else MsgBox AgentName & " not found" End If On Error GoTo 0 'reset error "Mike" wrote in message ... Hi. The following code finds a text string in worksheet "Blank 1". I need to have a msgbox come-up if the text is not found. How should I program so that an error won't throw the user into the module? myRow = Worksheets("Blank 1").Rows.Find (What:=AgentName).Row + 1 Thanks, Mike. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
If Error
Mike,
Try something like Dim FoundCell As Range Set FoundCell = Worksheets("Blank 1").Find(What:=AgentName) If FoundCell Is Nothing Then Msgbox "Not Found" Else MyRow = FoundCell.Row End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Mike" wrote in message ... Hi. The following code finds a text string in worksheet "Blank 1". I need to have a msgbox come-up if the text is not found. How should I program so that an error won't throw the user into the module? myRow = Worksheets("Blank 1").Rows.Find (What:=AgentName).Row + 1 Thanks, Mike. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Visual Basic Error Run Time Error, Type Mismatch | Excel Discussion (Misc queries) | |||
Error of slope taking into account error of the data points | Excel Worksheet Functions | |||
Counting instances of found text (Excel error? Or user error?) | Excel Worksheet Functions | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) |