05-08-2012, 04:19 PM
Thanks "ConstantChange" for posting this thread and for your proposed solution.
And thanks "Anshoo Arora" for your proposed solution, I tried it but it suffered also from the same problem that the "colTotal" always reads the first row columns. and the line "sData = ColInfoTable.GetCellData(rowStart,colStart)" needed small correction to be "sData = oTable.GetCellData(rowStart,colStart)". I've made small modifications to your function correcting the errors and adding 2 new parameters; the table as an input object and the table columns to make it more generic.
To call this function:
And thanks "Anshoo Arora" for your proposed solution, I tried it but it suffered also from the same problem that the "colTotal" always reads the first row columns. and the line "sData = ColInfoTable.GetCellData(rowStart,colStart)" needed small correction to be "sData = oTable.GetCellData(rowStart,colStart)". I've made small modifications to your function correcting the errors and adding 2 new parameters; the table as an input object and the table columns to make it more generic.
Code:
Public function getTargetRow(oTable, sText, colTotal)
rowTotal = oTable.GetROProperty("rows")
For rowStart = 1 to rowTotal
For colStart = 1 to colTotal
sData = oTable.GetCellData(rowStart,colStart)
If sData = sText Then
getTargetRow = rowStart
Exit Function
End If
Next
Next
End Function
To call this function:
Code:
Set myTableObject = Browser("myBrowser").Page(myPage").WebTable("myTable")
msgbox getTargetRow(myTableObject, "myText", 2)