×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Searching Column for text in Excel

Searching Column for text in Excel

Searching Column for text in Excel

(OP)
I am trying to search the first column of my excel document using EXTRA! Basic. How would I search that column for a specific text value and then return the row it was found out? Is this possible?

 

RE: Searching Column for text in Excel




CODE

dim xl as excel.application, lRow as long
...
lRow = xl.YourSheetObject.Columns(yourColumn).Find("YourFindValue").Row
 

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Searching Column for text in Excel

(OP)
This works great! However now I run into the problem, where if that certain text is not found then it returns an unknown value and stops my script. How do I handle the situation if the value is not found?

RE: Searching Column for text in Excel



CODE

dim xl as excel.application, lRow as long, rng as range
...
set rng = xl.YourSheetObject.Columns(yourColumn).Find("YourFindValue")

if not rng is nothing then
  lrow = rng.row
end if

...

set rng = nothing
   

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Searching Column for text in Excel

(OP)
I tried this, however Range must not be supported. Because it tells me 'Range' is not a record type. What could be the reason?

RE: Searching Column for text in Excel



as Excel.Range, programmer!

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Searching Column for text in Excel

(OP)
I tried that already. Still the same error. Yes I am a programmer and I usually don't have to use forums.  

RE: Searching Column for text in Excel



The try declaring rng as Object

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Searching Column for text in Excel

(OP)
I tried that yesterday and it worked. However once I do this, if it comes across something that is not in that column then the macro stops the macro and says Object value is set to Nothing; stopping macro playback. How could I avoid this?

RE: Searching Column for text in Excel




Please post your control code for this process.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close