I need to write in a column in Excel

Hey guys, I need to read columns “A” and “B” from Excel files using a “for each file” loop and write them into a target file. However, when I use the “write column” command, it overwrites the previous data instead of appending it.

I need it to write in sequence, like the auto-increment feature of the “write cell” command.

Hi @gustavo.souza ,

I believe you would require to add a condition in the For Each activity and use an If condition such that if it is the First iteration or first file, use Write Range activity and if it is other than the first file then use Append Range activity.

Let us know if you were able to understand the above approach.

Making it clearer so that everyone can understand and help me, I’ve been trying to do this for two days and I can’t.

This is my code now, only for column B9. It’s not everything, but the logic I need is the same. I want to read columns B9, C9, F9, and J9 from the files in a loop and paste them into an empty target Excel file on sheet1 in cells “A2”, “B2”, “C2”, and “D2”.

For example, file1 contains the rows in column B9 with the values “house”, “dog”, and “cat”, and file2 contains different values in column B9. The issue I’m having is that when the values from file2 are written to the target file, instead of starting from the first blank row and continuing the sequence of data from file1, it overwrites all the previously written data.

Hi @gustavo.souza

If you don’t want your destination data to be overwritten, you can go with the Append Range activity as @supermanPunch’s suggested. In this way, you can append the source data just below the last available range in the destination.

Best Regards.

I tried this, but I can’t get it to write in the column I want, it always writes in column “A1” because in the append range I can’t actually determine a column

@gustavo.souza

You can build a data table in the beginning of the workflow & start incorporating the read range data into it. Once you come out of the loop, you will have the complete data that needs to be appended, along with the relevant columns in place.

Hope this aligns with your requirement, please let us know if this is not what you are looking for.
Best Regards.

@gustavo.souza ,

Is it possible for you to provide us with a Sample Input and the Expected Output data in the form of Excel ?

We can work towards building the solution post providing the files, Else we would need more details from your end on the Excel data arrangement part. Does the data from B9 have the Column Names that needs to be included or is it just the values that you would want to retrieve ?

it does have a header, but I need to get only the column values, without headers, in column b9 I get the name of the farm for example.