How to move to a different cell of an excel sheet based on a match?

Viewed 166

I have an excel sheet in which I want to move to the next cell of same column if a match is true and then I need to get the content of that row in an array.

I am able to move to a different cell one time based on some defined value in column 0 but the next time if a match happens, I want to move to (row,col) (1,1) from (0,1), initially I am at (0,0). So, based on a match I am able to move to (0,1) but not able to move at (1,1) from (0,1).

for (my $i=$row_min; $i <= $row_max; $i++) 
{ 
    my $cell = $worksheet->get_cell($i , $col_min);
    next unless $cell;
    print("$cell\n");

    my $value =$cell->value();
    print("$value\n");
    my $s= $col_min + 1;
    if( defined $cell)
    {
        $cell =$worksheet->get_cell($i  , $s);
        $value =$cell->value();
        print("$cell\n");
        print("$value\n");

        if ($value =~ m/^PG$/i )
        {
            print("I am working\n");
            $cell=$worksheet->get_cell($row_min + 1,$s);
            next unless $cell=~ m/^WAC$/i;
            print("$cell\n");
            $value=$cell->$value();

            print("$value\n");
        }
    }
    else
        {
            print("\n");
        }
}
1 Answers
$cell=$worksheet->get_cell($row_min + 1,$s);

Perhaps you want to look at $i here instead of $row_min? $row_min has the same value on every row.

Related