Please Help

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

How do I change this to lookup a word in the range i specified. It works
with numbers but not letters

ans = Application.Match(CLng(TextBox2.Text), Range("A1:A100"), 0)


Thanks in advance

Greg
 
if isnumeric(Textbox2.Text) then
ans = Application.Match(CLng(TextBox2.Text), Range("A1:A100"), 0)
else
ans = Application.Match(TextBox2.Text, Range("A1:A100"), 0)
End if
 
CLng() converts the numeric string to real numbers.

If you drop that from your statement, you'll be looking for a text match:

ans = Application.Match(TextBox2.Text, Range("A1:A100"), 0)
 
Dropping the clng alone won't do if your A1:A100 contains a mix of numbers
and text (where cells have real numbers stored as numbers).

If that is the case, see my suggestion.
 
Yep.



Tom said:
Dropping the clng alone won't do if your A1:A100 contains a mix of numbers
and text (where cells have real numbers stored as numbers).

If that is the case, see my suggestion.
 
I used the code on each textbox on the form I needed to look up so I used
the number one on tb1 and the other code on tb 2& 3. Thanks for both your
help.

It runs perfect.

Greg
 

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

Similar Threads

Auto look up 1
Look up 4
Help with code please? 6
Match and Range Reference Syntax 3
Please check my code!!!! 1
Name look up 1
Difficulty with the property .Value of a Range 13
code crashing my programme??????? 4

Back
Top