title: Looping values from excel sheet in UFT
body: <p>Please can anyone help me !!!!</p>
  
  <p>I have this function that calls data from an external excel workbook and places the value into the application under test, I need it to loop through all the values in the excel sheet row by row</p>
  
  <p>Below is the link to the framework and the function I am trying to use and need it to loop through the values in the excel sheet. PLS HELP. </p>
  
  <p>MANY THANKS</p>
  
  <p><a href="http://www.automationrepository.com/2013/08/designing-hybrid-framework-in-qtp-part-3/" rel="nofollow">http://www.automationrepository.com/2013/08/designing-hybrid-framework-in-qtp-part-3/</a></p>
  
  <pre><code>'================================================================================
  'Function name - fnFetchDataFromExcelSheet
  'Description - This function retrieves the data from the excel sheet based upon the column name
  '================================================================================
  Function fnFetchDataFromExcelSheet(strColumnName)
  
      Dim sColValue
  
      'Initialize the return the value to "empty" string
      fnFetchDataFromExcelSheet = "empty"
  
      'Add a new blank sheet into the QTP data table
      'Excel data will be copied into this blank sheet
      DataTable.AddSheet("dtDataSheet")
  
      'Import the data from the excel sheet into the QTP data table
      DataTable.ImportSheet sExcelWorkbookPath, sSheetName, "dtDataSheet"
  
      'Find the value from the data table
      sColValue = DataTable.Value(strColumnName, "dtDataSheet")
  
      'Return the value back to the calling function
      fnFetchDataFromExcelSheet = sColValue
  
      'Remove Reference
      DataTable.DeleteSheet("dtDataSheet")
  
  End Function
  </code></pre>