![]() |
Programing with a "Find"
When a value is not found, the macro errors and stops. How can I trap the
error before it is reported and act on the error with out stopping the macro? Columns("F:F").Select Selection.Find(What:="347", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:= _ xlNext, MatchCase:=False).Activate |
Programing with a "Find"
You tell it to activate, but if it hasn't found anything, what is is
supposed to activate. Remove the activate, remove the problem. Dim rng as Range set rng = Columns("F:F").Find(What:="347", _ After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByColumns, _ SearchDirection:=xlNext, MatchCase:=False) if not rng is nothing then rng.activate Else msgbox "Not found" End if -- Regards, Tom Ogilvy PGibson wrote in message ... When a value is not found, the macro errors and stops. How can I trap the error before it is reported and act on the error with out stopping the macro? Columns("F:F").Select Selection.Find(What:="347", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:= _ xlNext, MatchCase:=False).Activate |
Programing with a "Find"
for some reason I need to select the range before using the set rng. this
works with the range select the other errors with unable to set column property ?? Can you explain? Sub AddToTotals(FindText As String) Range("f:f").Select Set RNG = Columns("F:F").Find(What:=FindText, After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:= _ xlNext, MatchCase:=False) If Not RNG Is Nothing Then RNG.Activate Call AddUp Else End If End Sub "Tom Ogilvy" wrote in message ... You tell it to activate, but if it hasn't found anything, what is is supposed to activate. Remove the activate, remove the problem. Dim rng as Range set rng = Columns("F:F").Find(What:="347", _ After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByColumns, _ SearchDirection:=xlNext, MatchCase:=False) if not rng is nothing then rng.activate Else msgbox "Not found" End if -- Regards, Tom Ogilvy PGibson wrote in message ... When a value is not found, the macro errors and stops. How can I trap the error before it is reported and act on the error with out stopping the macro? Columns("F:F").Select Selection.Find(What:="347", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:= _ xlNext, MatchCase:=False).Activate |
All times are GMT +1. The time now is 01:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com