How to add formula after inserting new column then stop once the row reached

I have a task where I need to add 2 columns, and I’ve already done that. What I need now is to put a formula in columns D and E, but it should skip the second row and stop once it reaches the row labeled ‘Total.’ Also, if the row contains ‘Dog,’ it should skip the second row again and plot the new formula there.

Hi @Elle ,
You can try to Find/Replace Value activity in UiPath.Excel.Acitivites package or you can try using a Macro to get the Cell address and get the row number from that. If you wanna use linq you skip rows using dt_Input.AsEnumerable().Skip(y) to skip rows where y is the number of rows you want to skip.

Hey @Elle,

Read the Excel into a DataTable.
Use a For Each Row loop with an index starting from row 3.
Inside the loop, use If row(“A”).ToString.Contains(“Total”) → Exit loop, and If row(“A”).ToString.Contains(“Dog”) → skip next row by increasing index.
For other rows, use Write Cell or Set Formula in columns D and E.
Finally, write the DataTable back to Excel.

Try and let me know.

1 Like