title: Scroll GuiGridView to find the row with a specific value in a given column
body: <p>I have created an Excel spreadsheet that extracts live data from a query in SAP GUI and paste that info back into Excel
  <img src="https://i.stack.imgur.com/CJtGv.jpg" alt="Extraction Pic" />.</p>
  <p>From there, I'm opening transaction ME38 to update schedule lines based off the extracted data.  I need to go to the &quot;scheduled..&quot; column (which I know to be &quot;txtEKET-MENGE&quot;) and change the number shown to the &quot;Qty Delivered&quot; (which is a part of the extraction); however, I need to only do this on certain cells in the &quot;Schedule...&quot; column (&quot;txtEKET-ETENR&quot;) [data listed on extraction as well].<br />
  <img src="https://i.stack.imgur.com/NAiao.jpg" alt="SAP Table Pic" /></p>
  <p>When it gets to &quot;Set grid...&quot; it ends the function and does nothing else.</p>
  <p>Any insight would be greatly appreciated.</p>
  <p>Here is what I've done so far.</p>
  <pre><code>Set xclapp = CreateObject(&quot;Excel.Application&quot;)
  Set xclwbk = ThisWorkbook
  Set xclsht = xclwbk.Sheets(&quot;Sheet1&quot;)
  For k = 2 To ActiveCell.SpecialCells(11).Row
  For j = 1 To ActiveCell.SpecialCells(11).Column
  If j = 14 Then Purch = xclsht.Cells(k, j).Value
  If j = 15 Then Item = xclsht.Cells(k, j).Value
  If j = 16 Then SLine = xclsht.Cells(k, j).Value
  If j = 8 Then PGI = xclsht.Cells(k, j).Value
  Next
  myTransaction = &quot;ME38&quot;
  
  Session.FindById(&quot;wnd[0]/tbar[0]/okcd&quot;).Text = &quot;/n&quot; &amp; myTransaction
  
  Session.FindById(&quot;wnd[0]&quot;).sendVKey 0
  
  On Error Resume Next
  Session.FindById(&quot;wnd[0]/usr/ctxtRM06E-EVRTN&quot;).Text = Purch
  Session.FindById(&quot;wnd[0]/usr/ctxtRM06E-EVRTN&quot;).caretPosition = 10
  Session.FindById(&quot;wnd[0]&quot;).sendVKey 0
  Session.FindById(&quot;wnd[0]/usr/txtRM06E-EBELP&quot;).Text = Item
  Session.FindById(&quot;wnd[0]/usr/txtRM06E-EBELP&quot;).caretPosition = 3
  Session.FindById(&quot;wnd[0]&quot;).sendVKey 0
  Session.FindById(&quot;wnd[0]/tbar[1]/btn[30]&quot;).press
  Session.FindById(&quot;wnd[0]/tbar[1]/btn[2]&quot;).press
  Call SelectRowOnGrid
  Session.FindById(&quot;wnd[0]/mbar/menu[0]/menu[0]&quot;).Select
  Session.FindById(&quot;wnd[0]&quot;).Close
    On Error Resume Next
  
    Session.FindById(&quot;wnd[1]/usr/btnSPOP-OPTION1&quot;).press
  Next
  End If
  If Err.Number &lt;&gt; 0 Then
  
  'The Excel worksheet has e.g. 3 columns of data and an error column.
  
  xclsht.Cells(j, 21).Value = &quot;Here is an error.&quot;
  
  Else
  
  xclsht.Cells(j, 21).Value = &quot;O.K.&quot;
  
  End If
  
  On Error GoTo 0
  </code></pre>
  <p>The following is the Function SelectRowOnGrid.</p>
  <pre><code>Function SelectRowOnGrid()
  Dim grid As SAPFEWSELib.GuiTableControl
  Dim columnname As SAPFEWSELib.GuiTableColumn
  Dim texttofind As String
  Set grid = Session.FindById(&quot;wnd[0]/usr/tblSAPMM06ETC_1117/&quot;)
  Set columnname = Session.FindById(&quot;wnd[0]/usr/tblSAPMM06ETC_1117/txtEKET-  ETENR&quot;)
  texttofind = xclsht.Cells(k, 16).Value
  
      For k = 0 To grid.RowCount - 1
  
  If grid.GetCellValue(k, columnname) = texttofind Then
  grid.SetCurrentCell
  grid.DoubleClickCurrentCell
  End If
  
      Next k
  
  End Function
  </code></pre>