Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search entire row for specified text 1

Status
Not open for further replies.

SuperKoopa

Technical User
Jul 30, 2012
26
0
0
US
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!
 
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,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
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!
 
Code:
If expression Then
   'TRUE result
Else
   'FALSE result
End If

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top