Find method example

  • Thread starter Thread starter Shinichi
  • Start date Start date
S

Shinichi

Hi All!

I need to find out if certain names exist in Worksheets
("Data").Range("A1:A300") in my application.
It should give boolean answer True or False.

So I would like to use "Find method" but I could not find
much answer in help file or MSDN library.

Can anyone tell me how to use find method please?

Thanks in advance,
Shinichi
 
Shinichi,

I like to use the CountIf function. (It has few if any errors)
Dim nm As String, x As Integer
nm = "z"
x = WorksheetFunction.CountIf(Sheets("sheet2").Range("A1:A300"), nm)
If x = 0 Then
MsgBox (nm & " not found")
Else
MsgBox (x & " occurance(s) of " & nm & " found")
End If

You can use a For .... Next loop to cycle through a list of names.
Or you can use an Input box for the user to enter a name to search for.
Amend the code to return True or False.

You could build this into a Function instead of a Sub.
 
Hi Steve,

Thanks for the help.
Yes, it works for my application.

Shinichi
 
Shinichi,

Great! There are many ways to get there, but this one appeals to me since
it doesn't have error issues to work around.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top