title: How to select current row in SAP GUI Grid View with VBA Macro?
body: <p>I am trying to automate a repetitive task in the SAP GUI. I need to search for an order number, select the row that the order number is in and then click a button to complete the task. I have recorded a macro which gives me:</p>
  
  <pre><code>session.findById("wnd[0]").maximize
  session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").pressToolbarButton "&amp;FIND"
  session.findById("wnd[1]/usr/txtGS_SEARCH-VALUE").text = "4521305207"
  session.findById("wnd[1]/usr/txtGS_SEARCH-VALUE").caretPosition = 10
  session.findById("wnd[1]/tbar[0]/btn[0]").press
  session.findById("wnd[1]/tbar[0]/btn[12]").press
  session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").currentCellColumn = ""
  session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").selectedRows = "2894"
  session.findById("wnd[0]/tbar[1]/btn[14]").press
  session.findById("wnd[1]/usr/chk[1,6]").selected = true
  </code></pre>
  
  <p>The line:</p>
  
  <pre><code>session.findById("wnd[1]/usr/txtGS_SEARCH-VALUE").text = "4521305207"
  </code></pre>
  
  <p>Corresponds to the order I want to search, but if I change this value it still tries to process the same order that the macro was recorded on, I'm assuming because of the line:</p>
  
  <pre><code>session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").selectedRows = "2894"
  </code></pre>
  
  <p>Does anyone know how I would go about finding the number of the row which corresponds to the outcome of the SEARCH-VALUE and then using that as the .selectedRows = ""?</p>