Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do I generate an error message such as "Macro will be aborted - The Find
Function cannot return a valid value" if the string "Cross" is not found in the selection. Selection.Find(What:="Cross", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Set cell = Selection.Find(What:="Cross", After:=ActiveCell,
LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) If cell Is Nothing Then MsgBox "Macro will be aborted - The Find Function cannot return a valid value" Exit sub end if -- HTH Bob Phillips (remove nothere from the email address if mailing direct) "Rafi" wrote in message ... How do I generate an error message such as "Macro will be aborted - The Find Function cannot return a valid value" if the string "Cross" is not found in the selection. Selection.Find(What:="Cross", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
use a range object and test if it is nothing something like this...
dim rng as range set rng = Selection.Find(What:="Cross", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) if rng is nothing then msgbox "Macro will be aborted - The Find Function cannot return a valid value" else rng.activate end if -- HTH... Jim Thomlinson "Rafi" wrote: How do I generate an error message such as "Macro will be aborted - The Find Function cannot return a valid value" if the string "Cross" is not found in the selection. Selection.Find(What:="Cross", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate Thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Rafi,
you could use this: Public Sub Find_Cross() Dim rngFound As Range Set rngFound = Selection.Find(What:="Cross", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) If rngFound Is Nothing Then MsgBox "Macro will be aborted - The Find Function cannot return a valid value" Else rngFound.Activate End If End Sub Did this help you? Best wishes, Eric "Rafi" wrote: How do I generate an error message such as "Macro will be aborted - The Find Function cannot return a valid value" if the string "Cross" is not found in the selection. Selection.Find(What:="Cross", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error Trapping from WSH | Excel Discussion (Misc queries) | |||
Error trapping | Excel Programming | |||
Error Trapping | Excel Programming | |||
error trapping | Excel Programming | |||
error trapping | Excel Programming |