How can i delete empty rows in an excel using for each row

You’re writing the entire data each time it loops, not just one row.

@postwick
So how can i fix that ?

Don’t loop. You don’t need to. You’re thinking of it as processing one row at a time, but that’s not how Read Range and Write Range work.

@postwick

My process is base on a list, to do the dispatch i need to loop on a list

i want to filter a excel file to take only the line i want.

If there is “Siege” front of the column A so it needs to go in excel file 1
If there is Nothing front of the column A so it needs to go in excel file 2

This is the original file :
image

To filter my excel file i use a list :

This is what i want :

Excel file Siege :
image

Excel file without Siege :
image

Create 3 datatables: sourceDT, SiegeDT, NothingDT

  • Read source file into datatable sourceDT
  • Loop through datatable as datarows datatype
    – If column index 1 has Siege, add row to SiegeDT
    – Else column index 1 has Nothing, add row to NothingDT
  • End Loop
  • Write SiegeDT and NothingDT to the appropriate Excel files
1 Like