Micro Focus QTP (UFT) Forums
Loop get excel value - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Loop get excel value (/Thread-Loop-get-excel-value)



Loop get excel value - gutocruz03 - 04-28-2010

Hi,

I´m from Brazil and i´m beginer in QTP, i need built one script where i get a first value in the excel (A,1) and after do something. After this, i will get next value in the excel (A,2). I can´t do this. I will need a loop but i can´t.

Tks,

Jose Augusto.


RE: Loop get excel value - basanth27 - 04-29-2010

Jose -
Can be easily done. Well, I suggest, henceforth you try search this forum before you post. The reason is you dont have to wait this long to get a simple query answered.

Here is the logic,

1. Establish connection with Excel using the COM.
2. Read the Excel Workbook.
3. Read the Excel Worksheet.
4. Find out how many total rows are available.
5. Form a For loop to iterate.
6. Check for "value" in the excel cell.

See if you can get this done & Good Luck buddy.


RE: Loop get excel value - bfakruddin - 04-29-2010

Hi,

Code:
Dim xl

Set xl=createobject("excel.application")

xl.workbooks.open("Path of xls file")
xl.visible=true

RC=xl.sheets("SheetID").usedrange.rows.count

set xl_A=xl.sheets("SheetID")

for i=1 to RC

    ur_lp=xl_A.cells(i,1).value
    print ur_lp

Next

set xl=nothing