View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Doug Glancy Doug Glancy is offline
external usenet poster
 
Posts: 770
Default Using Find method

Wade,

This will select it if it finds it and do nothing otherwise:

If Not Range("A1:A125").Find("Name") Is Nothing Then
Range("A1:A125").Find("Name").Select
End If

If you have multiple occurences of name you could modify this from xl2000
help:
"This example finds all cells in the range A1:A500 on worksheet one that
contain the value 2, and then it makes those cells gray."

Dim c As Range

Dim firstaddress As String



With Worksheets(1).Range("a1:a500")

Set c = .Find("Name")

If Not c Is Nothing Then

firstaddress = c.Address

Do

c.Interior.Pattern = xlPatternGray50

Set c = .FindNext(c)

Loop While Not c Is Nothing And c.Address < firstaddress

End If

End With




hth,



Doug




"wade " wrote in message
...
Hello - I am using a find method to search for a name in a given range.
For example, i use something like this,

Range("A1:A125").Find ("Name").select

to select the cell so that I can reference the row index. My problem
is handling those names that do not exist at the time.
The list will eventually have the name but at certain points of the
month it will not. how do i get around this problem. I have tried to
jusst through it into an error handler, but this is messy. Pls help

wade


---
Message posted from http://www.ExcelForum.com/