Thread: FIND AND COPY
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default FIND AND COPY

Judd,

If Not c Is Nothing Then
Set d = c.Offset(0,1).Resize(1,3)
FirstAddress = c.Address
Else
Exit Sub ' Or use Goto to skip to the next section of code
End If

HTH,
Bernie
MS Excel MVP


"Judd Jones" wrote in message
...
Bernie,

Thanks for all the help. One last question.

How do I get the code to exit out of the With statement if the value (1)
is
never found?

Thanks,
Judd

"Bernie Deitrick" wrote:

Judd,

Sorry for the misunderstanding.

With ActiveSheet.Range("A:A")
Set c = .Find(myFindString, LookIn:=xlValues, lookAt:=xlWhole)

If Not c Is Nothing Then
Set d = c.Offset(0,1).Resize(1,3)
FirstAddress = c.Address
End If

Set c = .FindNext(c)
If Not c Is Nothing And c.Address < FirstAddress Then
Do
Set d = Union(d, c.Offset(0,1).Resize(1,3))
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < FirstAddress
End If
End With

Should do it.

HTH,
Bernie
MS Excel MVP