Micro Focus QTP (UFT) Forums
EXCEL_ISSUE - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: EXCEL_ISSUE (/Thread-EXCEL-ISSUE)



EXCEL_ISSUE - bfakruddin - 02-08-2010

Hi,

I got a small issue while writing a script on excel file.

I created a excel object then I opened one existing excel file and copied some cells from some other excel which I want to do... till here it is working fine.

If I delete the content of the first excel file i.e., which I opened and copied content. I deleted all the content which I copied and again run the script to copy the same content from same file.

Here, I faced a problem... Row count is showing what it has after copying the cells previously. Now it is copying the content after the showing rowcount.

How it happened... How to resolve this...!

If you delete the total row then it is working fine...Just I wanna delete all the content in all cells which I was copied previously.


RE: EXCEL_ISSUE - Saket - 02-08-2010

may be you are using used rowcount. what you can do is when your perform delete, then set your rowcount back.


RE: EXCEL_ISSUE - bfakruddin - 02-08-2010

I used...

Code:
rc=xl.sheets("Sheet1").usedrange.rows.count

msgbox rc


it will give row count.... again I delete the cell contents manually... then I run above script.. It is giving row count which it has more than used (including copied rows)


RE: EXCEL_ISSUE - Saket - 02-08-2010

Yes, I guessed it right. when you use usedrange, it will take all the earlier pasted rows as used and so you are getting more than used.
how do you paste the content? try to set the rowcount back i.e if you are pasting from 1st row then at the time you delete the content set the row to start pasting back to 1.
or may be you can try deling the rows itself.