|
-
Aug 10th, 2012, 06:17 PM
#1
Thread Starter
Lively Member
[RESOLVED] find.next... (??)
Hey all,
Love the new look of the forum, Awesome!
straight to business...
I have a search script that i use to search two spacific columns in exel, the code (below) works well but stops dead when it finds just one search result. i would like it to be able to loop through to find more result IE: "Smith, john - Smith, Jane - Smith Blugh"
I've tried various attempts at: - Selection.FindNext (after:=ActiveCell).activate - and dim ExitLoop as boolean - Exit loop findnext...
but have drawn a blank... any help would be very much appreciated.
Cheers
Code:
Private Sub Cmd_OK_Click()
Dim MyText As String
Dim MyMsg As String
Dim MyType
Dim MyTitle As String
MyText = txtname.Value
MyText = TxtChange.Value
MyMsg = "No matches were found."
MyType = vbOKOnly + vbExclamation
MyTitle = "No Matches"
On Error GoTo ErrorHandler
Application.Goto Reference:="Name"
Selection.Find(What:=txtname, after:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
If txtname.Value = "" Then
Application.Goto Reference:="CO"
Selection.Find(What:=TxtChange, after:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
If TxtChange.Value = "" Then
Range("A1").End(xlDown).Select
End If
Exit Sub
ErrorHandler:
MsgBox MyMsg, MyType, MyTitle
End If
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|