A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Hi,
Your J loop starts from 0 . . so, 10 rows will be completed when J = 9 . . I have added a line that should exit the J loop when J = 10.
Hope it helps.
Set myGrid = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell")
allRows = myGrid.RowCount - 1 'number of SAP rows
allCols = myGrid.ColumnCount - 1 'number of SAP Columns
Dim SAPCOL As Object
Set SAPCOL = myGrid.ColumnOrder 'SAP column names in order in SAP window
For J = 0 To allRows
If J = 10 Then Exit For
myGrid.firstVisibleRow = J
For i = 0 To allCols
ActiveSheet.Cells(J + 1, i + 1).Value = myGrid.GetCellValue(J, SAPCOL(i)) 'starts in cell "A1"
Next i
Next J
If I was able to help You, please mark My response as answer and helpful.
Thank You!