PDA

View Full Version : Searching a record or row.



aligahk06
10-21-2009, 04:11 AM
Dear All,

I have an excel workbook in which more than 25000 rows ( Records ).
I want to find an individual row (record) with all column fields.
e.g Record Res pipe 4" 50 6 23.7 A particular record contains so many column fields.
I have an option through CTRL +F but we can not supply the entire fields.
Can i do this by macro.

Please assist ?

Rgds,
Aligahk06

p45cal
10-21-2009, 04:27 AM
Use the Autofilter?

mdmackillop
10-21-2009, 05:34 AM
Something like this? You'll need a way to provide the search data though.

Sub FindRecords()
Dim ToFind As String
Dim Records
Dim c As Range
Dim FirstAddress As String
Dim i As Long
Dim Found As Boolean
ToFind = "Data6"
Records = Array(1, 2, 3, 4)
With ActiveSheet.Range("a:a")
Set c = .Find(ToFind, LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
Found = True
For i = 0 To UBound(Records)
If c.Offset(, i + 1) <> Records(i) Then
Found = False
Exit For
End If
Next i
If Found Then MsgBox "Found at " & c.Address
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
End With
End Sub