Thread: Issue with Find
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Issue with Find

Hi Farooq

Try the below..

Sub Macro()
Dim ws As Worksheet, rngFound As Range

Set ws = Sheets("WAN")
Set rngFound = ws.Range("K2:K974").Find(What:="RTR23so-5/0/3",
LookAt:=xlWhole)

If Not rngFound Is Nothing Then
Sheets("LAHORE_1 P Router (RTR23)").Range("D9") = rngFound.Offset(0, -8).Value
Else
Sheets("LAHORE_1 P Router (RTR23)").Range("D9") = "Not found"
End If

End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Farooq Sheri" wrote:

I am using the following statements

Sheets("WAN").select
If (Range("K2:K974").Find(What:="RTR23so-5/0/3", LookAt:=xlWhole).Select) =
True Then
Sheets("LAHORE_1 P Router (RTR23)").Range("D9").Value = ActiveCell.Offset(0,
-8).Value
Else
Sheets("LAHORE_1 P Router (RTR23)").Range("D9").Value = "Not found"
End If

Everything is okay as long as the search string is found. If there is no
match, then an error is returned. I tried using "On Error resume Next" but
the resumption took place at the line immediately following the If statement.
I do not want this, rather I want the code to continue with the Else
statement.

Please help.

Thanks