Home > Blockchain >  proměnná I= i 1 dělá nepořádek s částí kódu (Rowcount - 4) Jak ignorovat proměnnou pro tuto část?
proměnná I= i 1 dělá nepořádek s částí kódu (Rowcount - 4) Jak ignorovat proměnnou pro tuto část?

Time:02-24

My variable doing mess with my part of code (Rowcount - 4, NETPR). Can I ignore this variable for this part and how?

'here is code to connect SAP

Dim ses As Object
i= 2
Do
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/ctxtP_VKORG-LOW").Text = "SOME"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellColumn = "ZGBSTD"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "ZGBSTD"
Dim myGrid As Object                                ' here I need ignore variable
Set myGrid = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell")           ' here I need ignore variable
With myGrid                                 ' here I need ignore variable
   .firstVisibleRow = .RowCount - 4                     ' here I need ignore variable
   Sheets("AB").Cells(i, 2).Value = myGrid.getcellvalue(.RowCount - 4, "NETWR") ' Here have to stay variable for Cells(i, 2) 
                                        ' but variable can't chnge RowCount- 4
End With
session.findById("wnd[0]/tbar[0]/btn[3]").press
i = i   1
Loop

'here is rest of code to end connection with SAP

CodePudding user response:

I have no idea what the program is supposed to do overall, but first I would clean up a bit and then see what's next.

for example:

'here is code to connect SAP

Dim ses As Object
Dim myGrid As Object
i= 2
Do
 session.findById("wnd[0]").maximize
 session.findById("wnd[0]/usr/ctxtP_VKORG-LOW").Text = "SOME"
 Set myGrid = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell")            
 myGrid.currentCellColumn = "ZGBSTD"
 myGrid.selectColumn "ZGBSTD"
 LastRow = myGrid.RowCount - 1 
 'every single value of the table 
 Sheets("AB").Cells(i, 2).Value = myGrid.getcellvalue(i - 2, "NETWR")
 'or always the last value 
 'Sheets("AB").Cells(i, 2).Value = myGrid.getcellvalue(LastRow - 3, "NETWR")
 session.findById("wnd[0]/tbar[0]/btn[3]").press
 i = i   1
 'without an exit, the loop runs indefinitely 
 if i - 2 > LastRow then exit do 
Loop

'here is rest of code to end connection with SAP

Regards, ScriptMan

  • Related