I want to create an algorithm to fix rows with errors

Hello.

I am a UiPath StudioX Enterprise Licence 2024.10.14 LTS user.

  1. Assumptions

I have a list variable lis_RowNo = {20,40,50} that stores the row numbers of blank rows in Excel.
After deleting the blank rows in Excel, I process the rows from top to bottom and store the row number where an error occurred in the Int32 variable int_ErrNo.

Since blank rows were initially present in Excel, the error row number stored in the Int32 variable int_ErrNo after deleting the blank rows is 30, but when considered against the original Excel sheet, the correct value is int_ErrNo = 29.

  1. What I want to do

Would it be possible to create an algorithm that uses the list variable lis_RowNo = {20,40,50} to correct the error row number in the Int32 variable int_ErrNo?

Hi @gorby ,

Yes. Assuming lis_RowNo contains the blank-row numbers from the original sheet and int_ErrNo is the original row number, use an Assign activity:

correctedRow = int_ErrNo - lis_RowNo.Count(Function(r) r < int_ErrNo)

For int_ErrNo = 30 and lis_RowNo = {20, 40, 50}, only row 20 is before row 30, so the result is 30 - 1 = 29. Use < because only blank rows before the error row should be counted.