Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Excel operation - to find usedrange of rows & col
#1
Not Solved
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

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
Reply
#2
Not Solved
You can get the total number of columns and then find the column number based on your columnname parameter. Then use the same in your code dynamically.

Please let me know if you need any more help on this.
Thanks,
SUpputuri
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiple rows of test data Bhuvana 0 1,358 01-03-2020, 09:30 PM
Last Post: Bhuvana
  The DataTable.ExportSheet operation failed. Invalid file. Niraj 2 6,315 05-05-2015, 11:40 PM
Last Post: babu123
  Adding data into rows that add dynamically with setcelldata azar81 4 5,968 04-13-2015, 05:24 PM
Last Post: vidya2k2
  where can I find the help for excel & database automation abhi_biradar2006 0 1,975 05-20-2014, 01:08 AM
Last Post: abhi_biradar2006
  how to count rows and columns in csv file. venkatesh9032 1 2,844 02-18-2014, 01:28 AM
Last Post: supputuri

Forum Jump:


Users browsing this thread: 1 Guest(s)