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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Or" Statement Question

Status
Not open for further replies.

vzachin

Technical User
Feb 10, 2006
305
US
Hi,

I'm looking for one of the following characters "C","D","M","V","AB","AD","AE" in Column 4, beginning with row 9 to 23, then get the corresponding string in Column 34.

Isn't there a better way to write the following code?

Here's my coding:
For x = 9 To 23 'row
For y = 34 To 34 'col

If Sess0.Screen.GetString(x, 4, 1) = "C" Or Sess0.Screen.GetString(x, 4, 1) = "D" Or Sess0.Screen.GetString(x, 4, 1) = "M" Or Sess0.Screen.GetString(x, 4, 1) = "V" Or Sess0.Screen.GetString(x, 4, 2) = "AB" Or Sess0.Screen.GetString(x, 4, 2) = "AE" Or Sess0.Screen.GetString(x, 4, 2) = "AE" Then
Lead = Sess0.Screen.GetString(x, y, 7)

End If

thanks
zach
 



Hi,

VB has the Select Case structure
Code:
For x = 9 To 23           'row
For y = 34 To 34          'col
        

Select Case Sess0.Screen.GetString(x, 4, 1)
   Case "C","D","M","V"
      Lead = Sess0.Screen.GetString(x, y, 7)
   Case "A"
      Select Case Sess0.Screen.GetString(x, 4, 2)
         Case "AB","AE"
             Lead = Sess0.Screen.GetString(x, y, 7)
      End Select
End Select

next:next


Skip,

[glasses] [red][/red]
[tongue]
 
Code:
If instr("CDMV",Sess0.Screen.GetString(x, 4, 1)) <> 0 or (Sess0.Screen.GetString(x, 4, 1) = "A" AND instr("BDE",Sess0.Screen.GetString(x, 5, 1)) <> 0) then
...

Calculus
 
thanks skip & calculus,

both methods work tremendously!

zach
 
one last question:

is there any way i can reference "C ","D ","M ","V ","AB","AD","AE" in Excel somehow? and then i can refer to this reference?

thanks
zach

 
More detail on the last question please.

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
You mean you want to pass both the criteria "C ","D ","M ","V ","AB","AD","AE" and the lead to excell?

C XXXXXXX
D XXXXXXX ...ect

what are you doing with the info in excel?
Are all C's going to one sheet, are all leads going to one column with their criteria in another?

Flesh it out a bit and I'm sure you'll get the help you need.

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
hi Mr Milson,

i can't believe i actually figured this one out.

i modified my coding as follows:
Code:
For x = 9 To 23
For j = 5 To 11
TypZ = Range("T" & j)
TypA = Sess0.Screen.GetString(x, 4, 2)
Lead = Sess0.Screen.GetString(x, 34, 7)
If TypA = TypZ  Then
Sess0.Screen.PutString Range("K1"), x, 34
Sess0.Screen.PutString "Y", 6, 58
Sess0.Screen.SendKeys ("<PF5>")
End if
next j
next x
[code]

TypZ is the range in Excel T5:T11 with my values. The only reason I'm doing this is so the enduser may & can change these values without me changing the coding.

again, thanks to all of you for your guidance and wisdom
zach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top