You may want to look at the FoundFiles property and object.
Ed
I looked at the FoundFile material in Help, and I'm not certain if I
didn't communicate what I'm looking for very well, or if you just
misunderstood. I'm refering to records within a worksheet.
After my macro performs a Find, the coding shown in my original post
will count how many were found, and when the UserForm comes up,
textbox15 will show that number. I want to attach a sequential number
to each of the found records, so that when the user clicks the Next or
Previous button on the form, I can show which record it is. Example 1
of 4, 2 of 4, etc.
If FoundFile WOULD apply to this, let me know, and I'll have to find
other resources for the command.
Thanks for your help.
J.O.
Ed - 22 Mar 2006 00:22 GMT
You are right - I goofed! FoundFiles only works with, well, files.
I have a macro that searches through a rnage on a sheet to find a text
string. When found, it writes the row number into an array. By iterating
through the array, I can get the row number of a certain item. Here is what
I have; I hope you can find something of use in it.
Ed
Sub SelectiveRowFind()
Dim myTarget As String
Dim myFind As Range
Dim rngSheet As Range
Dim rngLook As Range
Dim i As Integer, j As Integer
Dim x As Integer, y As Integer
Dim Cell As Object
Dim myFound() As Variant
Sheets("Sheet1").Activate
i = 0
j = 0
' Get text string to search for
myTarget = ""
myTarget = Application.InputBox("What text are you searching for?")
If myTarget = "" Or myTarget = "False" Then GoTo Bye
' Set range to used range on worksheet
If ActiveSheet.AutoFilterMode Then
Set rngSheet = ActiveSheet.AutoFilter.Range
Else
Set rngSheet = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
End If
' Resize range to exclude header row
Set rngSheet = rngSheet.Offset(1, 0).Resize(rngSheet.Rows.Count - 1)
' Do search
y = rngSheet.Rows.Count
For x = 1 To y
Set rngLook = rngSheet.Rows(x)
For Each Cell In rngLook
i = Cell.Row
If Not Rows(i).Hidden Then
Rows(i).Select
Set myFind = Rows(i).Find(What:=myTarget, LookAt:=xlPart)
If Not myFind Is Nothing Then
j = j + 1
ReDim Preserve myFound(j)
myFound(j) = i
GoTo NextRow
End If
End If
Next Cell
NextRow:
Next x
MsgBox "There were " & j & " matches found."
For x = 1 To j
MsgBox myFound(x)
Next x
Bye:
End Sub
>I looked at the FoundFile material in Help, and I'm not certain if I
> didn't communicate what I'm looking for very well, or if you just
[quoted text clipped - 11 lines]
> Thanks for your help.
> J.O.