cell,find Part 2

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a long customer list. I want to go to a certain
customer

When I use

Dim NameWant
Sub FindCustomer()

NameWant = Range("B1") 'In this case it equals "co"

Cells.Find(What:=NameWant, After:=ActiveCell,
LookIn:=xlValues, lookat:= _
xlWhole, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, MatchCase:=False) _
.Activate
Selection.End(xlToLeft).Select
End Sub

If you use "xlWhole" to query the list it doesn't return
anything because there is no cell in my list with
just "co"
When you use xlPart it returns the first customer that has
a "co" any where in the customer's name. I want find the
first customer that starts out with a "co"

oldjay
 
Try using xlwhole, but use:

what:=namewant & "*"

The asterisk is a wildcard here, too.
 
As I previously told you use

"co*"

with xlWhole

Cells.Find(What:=NameWant & "*", After:=ActiveCell,
LookIn:=xlValues, lookat:= _
xlWhole, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, MatchCase:=False) _
.Activate
 
Use the asterick (*) sign in searches
Example
Cells.Find(What:="co*", After:=ActiveCell,
LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, MatchCase:= _
False).Activate

Hope this helps
Peter Scott
Dublin
Ireland
 
Back
Top