Thread: FIND AND COPY
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Judd Jones[_2_] Judd Jones[_2_] is offline
external usenet poster
 
Posts: 12
Default FIND AND COPY

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