How to Filter an Excel Sheet for a Specific Item Code and Write to a New Sheet

Hello UiPath Community,

I have an Excel sheet containing different items, each with an ITEM_CODE and purchase dates. I want to:

  • Filter the sheet to get only the rows for a specific item code.
  • Write all the matching rows to a new sheet called “A4 Books”.

What’s the best way to do this in UiPath? I’m looking for a simple and reliable approach to filter the data and write it without leaving old data behind.

Thanks in advance for any guidance!

Hello @Daniel_Oisebe try this approach
first read the excel in a datatable as dtinput then use this linq to filter based on the code
dtfiltered = dtInput.AsEnumerable().Where(Function(row) row("ITEM_CODE").ToString.Trim = "A4").CopyToDataTable()
And Replace "A4" with the specific code then Write the filtered data to a new sheet

Cheers

Hi @Daniel_Oisebe

Use the Read Range activity to read the entire Excel sheet into a DataTable called DT1. Then use the Filter Data Table activity to filter rows from DT1 where ITEM_CODE equals the specific code you want and output the result to DTFiltered. After that, use the Write Range activity to write DTFiltered to a new sheet called “A4 Books,” making sure to overwrite any existing data.

If helpful, mark as solution. Happy automation with UiPath

@Daniel_Oisebe

first if you don’t want old data then you need to delete that first either by deleting the full sheet or use clear sheet to clear inly data

now use filter excel activity to filter with what you need and then use copy/paste range activity to copy data to new sheet

cheers

Hello @Daniel_Oisebe

Please try below flow

Forum_Filtertation_Task_26_09_2025.zip (3.2 KB)

Just replace your datatable variable

Regards,
Rajesh Rane

Thank you @bhavesh.choubey,
Any issue is I use the "“Equals” parameter to filter, rather than the “Trim”?

dtfiltered = dtInput.AsEnumerable().Where(Function(row) row(“ITEM_CODE”).ToString.Equals(“A4”).CopyToDataTable()

1 Like

Okay Glad it worked and you mean to say you replaced = with Equals() also the Trim() method is used to remove any spaces in the value.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.