×
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

Jobs

Search entire row for specified text

Search entire row for specified text

Search entire row for specified text

(OP)
Hello Tek-Tips!

I've learned so much here, its been really great! I had what hopefully is a quick question.

So I several attachmate screens full of paragraphs of text. This text may or may not contain a certain value. I need each row ( rows 3 to 22) to be "scanned" for this text which is shorter than the column lengths. If the text exists then I need cell in Excel A1 to return "YES". Below I will provide an example to illustrate what I'm trying to do.

ATTACHMATE SESSION SCREEN 03/25/13 07:56:38
-----------------------------------------------------
THIS IS A SAMPLE PARAGRAPH REPRESENTING THE TEXT I NEED TO SEARCH IN. THE FOLLOWING IS THE TEXT I NEED "PULL ME!". THE REST OF THE TEXT WILL GO ON FOR SEVERAL SCREENS WHICH I CAN ALREADY ACCOUNT FOR.

So the code would need to look at each row and find "PULL ME!" on row 2, column 39 (or at whatever column it starts) and is 8 characters long. The text I need to pull is a constant value. The rows need to vary so im assuming it would start something like:

For nRow = 3 To 22

If Sess0.Screen.GetString(nRow, now sure how to account for row and length) = "PULL ME!" Then
ActiveSheet.Range("A1") = "Yes"
Else
Next nRow
End If

Forgive me if that is very incorrect (im sure theres some String code that should be there), but I just want to make sure I clearly express what I'm trying to do. I appreciate your time reading this!

RE: Search entire row for specified text

hi,

CODE

For nRow = 3 To 22
        If Trim(Sess0.Screen.GetString(nRow, 2, 79)) Like "*PULL ME*" Then
            ActiveSheet.Range("A1") = "Yes"
            Exit For
        End If
    Next nRow 
I assume that your emulator displays 80 columns and column 1 contains non-display control characters.

Use the Like operator with wildcards.

Once you find the string, there is no need to continue the loop.

Skip,

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

RE: Search entire row for specified text

(OP)
Hey Skip thank you very much! That works perfectly! Do you know how I can account for when the text doesn't exist? I thought maybe I coulda just put an Else ActiveSheet.Range("A1") = "No" statement. Sorry! As always I appreciate your help!

RE: Search entire row for specified text

CODE

If expression Then
   'TRUE result
Else
   'FALSE result
End If 

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