Looping through For Each

Hello,

I am trying to loop through an excel column called ‘Customer’ (the column stores a list of customers) and I want to add in an extra line with the word break every time the customer name changes. Does anyone know the best way to do this?

See screen grab below. Thanks

  1. read excel range to a datatable
  2. initialize empty new datatable
  3. loop first datatable, storing current and previous customer names
  4. add current customer name to new datatable
  5. if theres a difference between current and previous customer, then add a new row with the work “break” to new datatable
  6. write new datatable to excel, replacing the old one

Here is my sequence, remember to change the excel path to your own path

Sequence.xaml (11.7 KB)

Before:
image

After
image