Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GetRowWithCellText does not work if the header has a colspan
#3
Solved: 10 Years, 10 Months ago
Hi!

In advance: This is solved, I created my own function and that actually works..

But @Anshoo: No, this function is supposed to return a row number for a given text, so if there is a table and somehwhere in line 3 the word "test" occurs, normaly the this call GetRowWithCellText("text") should return 3. But that does not always work. Thanks anyway though! Smile

In case somebody wants to use my function, here it is. Its not very elegant, but I came to the conclusion that VBScript (or lets say the DotNet Object Model) does not want us to be elegant...

Code:
Function getTableRowWithText(table, textToFind, exact, uncountHeader)
    rows=table.rowCount()
    getTableRowWithText=-1
    if(table is nothing or textToFind="" or rows<1) then
        Exit function
    end if
    For i=1 to rows
        For j=1 to table.columnCount(i)
            val=table.getCellData(i, j)
            if(exact) then
                if(val=textToFind) then
                    getTableRowWithText=i
                    if(uncountHeader) then
                        getTableRowWithText=getTableRowWithText-1
                    end if
                    Exit function
                end if
            else
                if(instr(val, textToFind)>0) then
                    getTableRowWithText=i
                    if(uncountHeader) then
                        getTableRowWithText=getTableRowWithText-1
                    end if
                    Exit function
                end if
            end if
        Next
    Next
End Function
Reply


Messages In This Thread
RE: GetRowWithCellText does not work if the header has a colspan - by ConstantChange - 05-09-2008, 02:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Set the column header in the excelsheet before importing it to local datasheet nageshpv 2 3,230 08-04-2008, 04:05 PM
Last Post: nageshpv

Forum Jump:


Users browsing this thread: 1 Guest(s)