Hi Anil,
In your case, you do not need to create the counter. You need to get the total number of rows in the Excel sheet and use this value for the verification. To obtain this value, you can use the Excel.Application COM object. For more information, please read
Working With Excel Files via COM in the online documentation.
For example, you can modify your script in the following way:
Sub ArrayTesting
ArrayTesting
' Get the total number of rows
Dim Excel, RowCount
Set Excel = Sys.OleObject("Excel.Application")
Excel.Workbooks.Open("E:\Anil-Backup\Test Complete\Projects_Old\In4Suite Project\ExcelFile\Rental Database\RentalTermSheet.xlsx")
RowCount = Excel.ActiveSheet.UsedRange.Rows.Count
' Iterate through the storage
Set MyDDTObject = DDT.ExcelDriver("E:\Anil-Backup\Test Complete\Projects_Old\In4Suite Project\ExcelFile\Rental Database\RentalTermSheet.xlsx", "Sheet1", true)
While Not MyDDTObject.EOF()
If RowCount = 2 Then
Log.Message RowCount
Log.Message(MyDDTObject.Value(0))
Log.Message(MyDDTObject.Value(1))
Log.Message(MyDDTObject.Value(2))
Else
Log.Message(MyDDTObject.Value(0))
Log.Message(MyDDTObject.Value(1))
'Log.Warning "data not found"
MyDDTObject.Next
RowCount = RowCount + 1
End If
WEnd
DDT.CloseDriver(MyDDTObject.Name)
End Sub