View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
gocush[_7_] gocush[_7_] is offline
external usenet poster
 
Posts: 1
Default Use excel as a searcher


You could try the following code in a vba module:

First name 2 ranges
"Database" as the cells in you DB
"KeyWord" as a single cell ABOVE your db or on another sheet.


Option Explicit

Sub SearchDB()
Dim oCell As Range
Dim r As Range
Dim Found As Boolean
Dim KWord As String
Dim firstAddress As String

KWord = Range("KeyWord")

For Each r In Range("Database").Rows
Found = False
With r
Set oCell = .Find(KWord, LookIn:=xlValues)
If Not oCell Is Nothing Then
firstAddress = oCell.Address
Do
Found = True
Set oCell = .FindNext(oCell)
Loop While Not oCell Is Nothing And oCell.Address <
firstAddress
End If
If Not Found Then r.EntireRow.Hidden = True

End With
Next


End Sub


TO SHOW YOUR DATABASE again, RightClick all rows in the DBUnhide

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com