Excel Task Takes Too Long to Run – Need Help Optimizing Workflow

Hi UiPath Community,

I’ve built a workflow in UiPath where I:

  1. Read data from an Excel file
  2. Filter rows where Posting Key = “40”
  3. Write filtered results back to the same sheet (e.g., “SABB”)
  4. Add a “Total” row at the end of the Amount in local currency column

The logic works fine, but the workflow takes a long time to run, especially as the number of rows grows. It sometimes freezes or delays heavily when writing the data or calculating the total.

Here’s what I’m currently doing:

  • Reading Excel using Read Range
  • Filtering with a For Each Row and If condition
  • Summing with a loop
  • Writing each row in the output sheet
  • Adding total with another Append range

:red_question_mark:What I Need Help With:

  • How can I speed this up to (5 to 10 minites)?
  • Should I use Filter DataTable or LINQ instead of looping?
  • What’s the fastest way to write data and totals to Excel?
    in the excel file have 17500 row

Thanks in advance for your help! :folded_hands:
– Musthak

@Mohamad_Musthak,

Try this approach.

  1. Don’t read data from an Excel file. Just Open the excel file using Excel Process Scope and Use Excel File activity
  2. Filter rows where Posting Key Not equal to “40” using Filter activity to apply filter on excel file.
  3. Use Delete Rows activity to delete the filtered unwanted rows.
  4. Now you will have the required data where Posting Key = “40”. Add a “Total” row at the end of the Amount in local currency column

i already try this bro
but still take more than 2 to 3 hours

@Mohamad_Musthak,

Try running the bot with Profile Execution enabled and observe which activities are taking how much time to find the pain points.

1 Like

how to enable this bro

@Mohamad_Musthak,

Just click on it once and it should look like this one

@Mohamad_Musthak

In excel process scope..select process mode as automation,kill when session exists,disable macros this will make sure it is faster

Cheers

still same problem bro

@Mohamad_Musthak You can write VBA code and use Activities - Invoke VBA activity. It does not require an .xlsm Excel file.

Hi @Mohamad_Musthak

Could you please try with the extension method or LINQ mentioned in the below doc? These both are faster. Try with both one by one and see which one gives you faster response.

Also linking 1 forum post that shares LINQ syntax for such scenario.

Hope this helps.

Regards
Sonali

1 Like

@Mohamad_Musthak it takes 2 seconds with 20000 rows.


Code.zip (246.5 KB)

3 Likes

Error bro
Invoke VBA: Programmatic access to Visual Basic Project is not trusted

Make sure you enable macros in your Excel settings.

this step here is what causing high execution time. Not sure why you are writing for each Row :confused:. Imagine opening excel, writing some data, saving, closing it and doing it for 17500 times

When you are in loop update your data in datatable itself and use Add Data Row to add the Total amount and only once write it back to excel file. You might need to clear the Sheet before writing the data, if possible create a new file.

for below: Are you summing the numbers in loop itself?

1 Like