i need some help here, i have a command for script sap(vba) where i just need to change a number am each line, is there a way to have just one line and create a loop? num1 = 5, num2 = 9, num3 = 10
session.findById("wnd[1]/usr/chk[2,5]").Selected = True
session.findById("wnd[1]/usr/chk[2,9]").Selected = True
session.findById("wnd[1]/usr/chk[2,10]").Selected = True
what i hope
session.findById("wnd[1]/usr/chk[2,numX]").Selected = True
CodePudding user response:
for example:
For numx = 5 To 13 Step 4
If numx = 13 Then numx = 10
session.findById("wnd[1]/usr/chk[2," & cstr(numx) & "]").Selected = True
next
Regards, ScriptMan
CodePudding user response:
Another way using a For Each loop.
Sub Test()
Dim vNums() As Variant
vNums = Array(5, 9, 10)
Dim vNum As Variant
For Each vNum In vNums
session.findById("wnd[1]/usr/chk[2," & vNum & "]").Selected = True
Next vNum
End Sub