Loop condition

I have a problem

that in this picture i want to write in excel by the given formula but i want this to be done in loop. loop until when it find the last non blank cell and then stop.

1 Like

Hi,

You will have to make an expression that converts the loop index to the required target and value string for the Write Cell activity. Ideally, run the index from the same row number as the Excel data, so you can write "C" & row.ToString as the target cell and String.Format("=MAX(E{0}:BB{0})-E{0}", row) as the cell value. For the loop condition you can use similar syntax to Read Cell on the current (Do loop) or next cell (Do While loop) and then check that β€œreadValue IsNot Nothing” (i.e. the value just read is not null).

2 Likes

Hello,

You don’t want to do a loop on a formula. There is a Filldown keystroke combination you can use. - Ctrl+D

Select Range

TypeInto
β€œ[d(ctrl)]d[u(ctrl)]”

For the Select Range you will need to use a datatable from Read Range I think to get the Row count. so range might be β€œB”+row.ToString+β€œ:B”+(dt.Rows.Count+1).ToString

My 2 cents.
Thanks.

5 Likes

Thanxx ClaytonM it is working.