Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to give the For Loop for 3 work sheets?
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi,
I am opening a excel sheet from QTP.
This is my following code.
Code:
Set xlWrkbk = xlApp.Workbooks.Open("C:\New Folder\RETS.xls")
Set xlWrksht = xlWrkbk.Worksheets("MD")
Set xlWrksht1 = xlWrkbk.Worksheets("Obj")
Set xlWrksht2 = xlWrkbk.Worksheets("Sea")
'Metadat is the name of the  Excel sheet
intStartRow=1
'Declare the starting row
For intRow = intStartRow to xlWrksht.UsedRange.Rows.Count

Gmd= xlWrksht.Range("A" & intRow)
ID = xlWrksht.Range("B" & intRow)
Format  = xlWrksht.Range("C" & intRow)
Res= xlWrksht1.Range("A" & intRow)
Type1 = xlWrksht1.Range("B" & intRow)
ID1= xlWrksht1.Range("C" & intRow)
...............
Next
In the for loop I am asking to check the rows in the sheet

For
Code:
intRow = intStartRow to xlWrksht.UsedRange.Rows.Count

It checks all the 4 rows and it displays the correct result.

If it work with the 2nd and 3rd sheet it doesnot work properly.
It checks all the rows and again it tries to get inside and
giving invalid procedure call or argument error.

How to solve it?Any idea?

Thanks,
Uma
Reply


Messages In This Thread
How to give the For Loop for 3 work sheets? - by Uma - 09-10-2011, 03:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare Two ex cel sheets and highlight differences neerukonda9 17 14,069 06-03-2020, 12:04 PM
Last Post: rajrk
  This code does not give total no of links present on page plz help it returns 0 excellentpawan 8 5,636 01-17-2015, 07:49 PM
Last Post: yogi4tech
  Comparing two excel Sheets whose columns names vary Divya Roopa 2 8,652 03-26-2014, 07:20 PM
Last Post: Parke
  Iteration in Local sheets for UFT11.5 haithamQTP 1 3,203 02-27-2014, 09:12 AM
Last Post: supputuri
  FOR LOOP shayk1985 1 5,307 12-13-2012, 11:35 AM
Last Post: sams001

Forum Jump:


Users browsing this thread: 1 Guest(s)