PDA

View Full Version : [SOLVED] Search a worksheet



austenr
04-29-2005, 10:29 AM
I have a need to search a list and display the data. I want to search for a name, not case sensitive. Tried to record one and copy it but the macro was empty. Any suggestions?

Zack Barresse
04-29-2005, 10:48 AM
Hi Austen,

Can you explain a little more? Define "search a list". And display the data where? On a new worksheet? In a message box?

Jacob Hilderbrand
04-29-2005, 10:50 AM
Try this:



Option Explicit

Sub Macro1()
Dim Cel As Range
Dim FirstAddress As String
With Range("A:A")
Set Cel = .Find(What:="Test", LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=False)
If Not Cel Is Nothing Then
FirstAddress = Cel.Address
Do
MsgBox Cel.Address
Set Cel = .FindNext(Cel)
Loop While Not Cel Is Nothing And Cel.Address <> FirstAddress
End If
End With
End Sub

austenr
04-29-2005, 10:54 AM
Thanks Jake

Jacob Hilderbrand
04-29-2005, 10:58 AM
You're Welcome :beerchug:

Take Care

Zack Barresse
04-29-2005, 11:18 AM
You may also want to check out this article by Johnske: http://www.vbaexpress.com/forum/articles.php?action=viewarticle&artid=5