Searching a row ( record )

A

Aligahk06

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
 
J

Jacob Skaria

Try out the below macro...You can specify the data to be searched in the
variable varSearch as string columns separated by a pipe symbol. The below
macro check for a data in 1 2 3 in ColA ColB and ColC


Sub FindRowData()
'Jacob Skaria
Dim varFound As Variant, varSearch As Variant
Dim strAddress As String, arrSearch As Variant
Dim blnMismatch As Boolean, blnFound As Boolean

varSearch = "1|2|3"
arrSearch = Split(varSearch, "|")

ActiveSheet.UsedRange.Font.ColorIndex = 0
With ActiveSheet.Columns(1)
Set varFound = .Find(arrSearch(0), _
LookIn:=xlValues, LookAt:=xlWhole)
If Not varFound Is Nothing Then
strAddress = varFound.Address
Do
blnMismatch = False
For intTemp = 1 To UBound(arrSearch)
If CStr(varFound.Offset(, _
intTemp)) <> arrSearch(intTemp) Then _
blnMismatch = True: Exit For
Next

If Not blnMismatch Then Exit Do

Set varFound = .FindNext(varFound)
Loop While Not varFound Is Nothing And _
varFound.Address <> strAddress
If Not blnMismatch Then
varFound.Resize(, intTemp).Font.ColorIndex = 3
Application.Goto varFound, True
blnFound = True
End If
End If
End With

If Not blnFound Then MsgBox "Cannot find the data" & _
vbLf & vbLf & varSearch

End Sub

If this post helps click Yes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top