Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using Find method

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 proble
is handling those names that do not exist at the time.
The list will eventually have the name but at certain points of th
month it will not. how do i get around this problem. I have tried t
jusst through it into an error handler, but this is messy. Pls help

wad

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Using Find method

Hi wade

One way is to use a On Error Resume Next


On Error Resume Next
Range("A1:A125").Find("Name").Select
On Error GoTo 0


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"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/



  #3   Report Post  
Posted to microsoft.public.excel.programming
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/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Using Find method

Dim rngToFind as Range
On Error Resume Next
Set rngToFind = Range("A1:A125").Find(What:="Name")
On Error Goto 0
If Not rngToFind Is Nothing Then
rngToFind.Select
End If

Perhaps Match would suit better since you are applying some kind of indexing
system. Match returns the relative position of an item within a list.
Dim varRes as Variant
varRes = Application.Match("Name", Range("A1:A125"),0)
If Not isError(varRes) Then
Msgbox "index position is " & varRes
Else
Msgbox "Couldn't find it."
End If


"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/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
find method? CG Rosén Excel Programming 2 November 12th 03 10:30 AM
Find method example Shinichi Excel Programming 3 August 22nd 03 10:39 PM
The find method Stuart[_6_] Excel Programming 0 August 5th 03 03:14 PM
Help with the Find method Mike NG Excel Programming 3 August 4th 03 07:15 PM
The Find Method Dick Kusleika Excel Programming 3 July 16th 03 07:59 PM


All times are GMT +1. The time now is 03:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"