Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Search Box to Workbook 1

Status
Not open for further replies.

NumberCrunchingMonky

Technical User
Feb 5, 2004
30
US
I've scoured probably 200 archives looking for this solution and I cannot find it...

How can I add a Search Box to a worksheet? I want to configure it so that:
- I type the name in a cell (let's say its D1)
- Column A is queried
- The cell in Column A that contains the word typed in D1 is selected

Thanks.

Monky
 
Something like the following (not tested)

This will select the cell with the first occurrence of the search criteria.
Code:
Dim i, szSearch
szSearch = shtObj.Range("D1").Value
For i = 1 To shtObj.UsedRange.Rows.Count Step 1
    If shtObj.Range("A" & i).Value = szSearch
        shtObj.Range("A" & i).Select
        End
    End if
Next i

*cLFlaVA
----------------------------
A polar bear walks into a bar and says, "Can I have a ... beer?"
The bartender asks, "What's with the big pause?
 
Thanks cLFLaVA--I appreciate your help.
I'm having an issue with line 4, though:
"If shtObj.Range("A" & i).Value = szSearch"
Thanks.
Monky
 
What is the error you're getting?

*cLFlaVA
----------------------------
A polar bear walks into a bar and says, "Can I have a ... beer?"
The bartender asks, "What's with the big pause?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top