02-17-2015, 10:13 PM
Hi,
I am very much new to Qtp,
I am trying to write some data to excel sheet.
I want to get the usedrange of rows in Excel and write the data in next available row, by passing the column name as parameter.
Kindly help me with this.
Ex: Excel sheet somthing like this
Name ID Ph
aa 12 52451
bb 5 5654
ws.cells(Next_Row_Range,columnname).value ="abc" -> i am going wrong here. I wanna pass the columnname & write data into next available row in particular column.
Thanks in advance.
Regards,
Pooja
I am very much new to Qtp,
I am trying to write some data to excel sheet.
I want to get the usedrange of rows in Excel and write the data in next available row, by passing the column name as parameter.
Kindly help me with this.
Ex: Excel sheet somthing like this
Name ID Ph
aa 12 52451
bb 5 5654
Code:
Function XXX(Byval path,Byval sheetname,Byval columnname)
Dim objXL,wkb,ws
Set objXL = CreateObject("Excel.Application")
objXL.visible = True
Set wkb = objXL.Workbooks.Open(path)
Set ws = wkb.Sheets(sheetname)
ws.Activate
iRows = ws.UsedRange.Rows.count
icol = ws.usedRange.columns.count
Next_Row_Range = iRows +1
Add_Column_Range = icol +1
ws.cells(Next_Row_Range,columnname).value ="abc"
End Function
ws.cells(Next_Row_Range,columnname).value ="abc" -> i am going wrong here. I wanna pass the columnname & write data into next available row in particular column.
Thanks in advance.
Regards,
Pooja