I made a script with a loop to carry out several items from a file, but the transaction has a limit of 10 items, and the files 15 or more, I need help so that the script understands that it needs to scroll down when it has no empty lines
For Each cel In rng
If IsEmpty(cel.Value) Then
Exit For
End If
Session.findById("wnd[0]").sendVKey 4
Session.findById("wnd[1]/usr/tabsG_SELONETABSTRIP/tabpTAB001/ssubSUBSCR_PRESEL:SAPLSDH4:0220/sub:SAPLSDH4:0220/txtG_SELFLD_TAB-LOW[0,24]").Text = cel.Value
Session.findById("wnd[1]/usr/tabsG_SELONETABSTRIP/tabpTAB001/ssubSUBSCR_PRESEL:SAPLSDH4:0220/sub:SAPLSDH4:0220/txtG_SELFLD_TAB-LOW[0,24]").caretPosition = 19
Session.findById("wnd[1]").sendVKey 0
cel.Offset(0, 1) = Session.findById("wnd[1]/usr/lbl[49,3]").Text
Session.findById("wnd[1]/usr/lbl[49,3]").caretPosition = 5
Session.findById("wnd[1]").sendVKey 2
Session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1200/subSUB_AVO_KOMP:SAPLCOIH:1206/tabsTS_1206/tabpKPVG/ssubSUB_AVO_OVERVIEW:SAPLCOMK:3010/tblSAPLCOMKTCTRL_3010/txtRESBD-MENGE[4," & CInt(contador) & "]").Text = Cells(contador2, 7).Value
Session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1200/subSUB_AVO_KOMP:SAPLCOIH:1206/tabsTS_1206/tabpKPVG/ssubSUB_AVO_OVERVIEW:SAPLCOMK:3010/tblSAPLCOMKTCTRL_3010/ctxtRESBD-POSTP[6," & CInt(contador) & "]").Text = "n"
Session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1200/subSUB_AVO_KOMP:SAPLCOIH:1206/tabsTS_1206/tabpKPVG/ssubSUB_AVO_OVERVIEW:SAPLCOMK:3010/tblSAPLCOMKTCTRL_3010/ctxtRESBD-POSTP[6," & CInt(contador) & "]").SetFocus
Session.findById("wnd[0]").sendVKey 0
If Session.ActiveWindow.Name = "wnd[1]" Then
Session.findById("wnd[1]/tbar[0]/btn[0]").press
End If
Session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1200/subSUB_AVO_KOMP:SAPLCOIH:1206/tabsTS_1206/tabpKPVG/ssubSUB_AVO_OVERVIEW:SAPLCOMK:3010/tblSAPLCOMKTCTRL_3010").getAbsoluteRow(contador).Selected = True
Session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1200/subSUB_AVO_KOMP:SAPLCOIH:1206/tabsTS_1206/tabpKPVG/ssubSUB_AVO_OVERVIEW:SAPLCOMK:3010/tblSAPLCOMKTCTRL_3010/txtRESBD-POSNR[0," & CInt(contador) & "]").SetFocus
Session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1200/subSUB_AVO_KOMP:SAPLCOIH:1206/tabsTS_1206/tabpKPVG/ssubSUB_AVO_OVERVIEW:SAPLCOMK:3010/btnBTN_EINK").press
Session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1300/tabsTS_1300/tabpEINK/ssubSUB_KMP_DETAIL:SAPLCOMD:3170/txtRESBD-GPREIS").Text = ThisWorkbook.Worksheets("Planilha1").Cells(contador2, 9).Value
If Session.ActiveWindow.Name = "wnd[1]" Then
Session.findById("wnd[1]/tbar[0]/btn[3]").press
End If
Session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1300/tabsTS_1300/tabpEINK/ssubSUB_KMP_DETAIL:SAPLCOMD:3170/ctxtRESBD-LIFNR").Text = Cells(2, 13).Value
Session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1300/tabsTS_1300/tabpEINK/ssubSUB_KMP_DETAIL:SAPLCOMD:3170/txtRESBD-AFNAM").Text = Cells(1, 13).Value
Session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1300/tabsTS_1300/tabpEINK/ssubSUB_KMP_DETAIL:SAPLCOMD:3170/txtRESBD-BEDNR").Text = "2"
Session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1300/tabsTS_1300/tabpEINK/ssubSUB_KMP_DETAIL:SAPLCOMD:3170/ctxtRESBD-LIFNR").SetFocus
Session.findById("wnd[0]").sendVKey 0
Session.findById("wnd[0]").sendVKey 0
Session.findById("wnd[0]").sendVKey 0
Session.findById("wnd[0]/tbar[0]/btn[3]").press
If Session.ActiveWindow.Name = "wnd[1]" Then
Session.findById("wnd[1]/tbar[0]/btn[3]").press
End If
Session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1200/subSUB_AVO_KOMP:SAPLCOIH:1206/tabsTS_1206/tabpKPVG/ssubSUB_AVO_OVERVIEW:SAPLCOMK:3010/tblSAPLCOMKTCTRL_3010").getAbsoluteRow(contador).Selected = False
Session.findById("wnd[0]").sendVKey 4
Session.findById("wnd[0]").sendVKey 0
contador = contador + 1
contador2 = contador2 + 1
Next cel