Function CopyrowfromExcel(strpath, Location, strTCRefval)
Dim arr(52)
Sheet=Location
Datatable.AddSheet Sheet
Set ObjectExcelApp = CreateObject("Excel.Application")
'Handling the Run time errors
On Error Resume Next
Err.Clear
Set ObjWorkbook=ObjectExcelApp.Workbooks.open (strpath)
Set ObjExcelSheet=ObjectExcelApp.worksheets(Trim(Sheet))
Rowscount=ObjExcelSheet.usedrange.rows.count
Columncount=ObjExcelSheet.usedrange.columns.count
'Below statements take column headers from external excel file andadd sameheaders to datatable
'Confirm there should not be any column header in the QTP datasheet
For j=1 to Columncount
ColumnHeader=ObjExcelSheet.cells(1, j).value
DataTable.GetSheet(Sheet).AddParameter ColumnHeader, ""
Next
'Below statements take desired row values and update in datatable
Flag=0
For k=1 to Rowscount
'Here I assume that first row always 'TCRef'.
strTCRef=ObjExcelSheet.cells(k, 1)
It's amazing for me to have a web page, which is good for my know-how. thanks admin
ReplyDeletemy web site: What Is The Diet Solution