# UiPath Datatable Loop Performance Issue

**URL:** <https://forum.uipath.com/t/uipath-datatable-loop-performance-issue/187994>\
**Category:** Help\
**Tags:** bestpractices, datatable, question, excel, system, activities\
**Created:** [January 24, 2020, 8:47am UTC](https://forum.uipath.com/t/uipath-datatable-loop-performance-issue/187994 "2020-01-24T08:47:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![marci080](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marci080/32/54713_2.png) [@marci080](https://forum.uipath.com/u/marci080)\
**Post date:** [January 24, 2020, 8:47am UTC](https://forum.uipath.com/t/uipath-datatable-loop-performance-issue/187994/1 "2020-01-24T08:47:25Z")

</div>

> [@Best Practices in Excel - Invoking VBA vs. UIPath Data Table Activities](https://forum.uipath.com/t/best-practices-in-excel-invoking-vba-vs-uipath-data-table-activities/169966):
>
> I’m preparing a POC for my first automation proyect with UIYPath, a process in which 90% is formatting, filtering, inserting and removing rows in Excel. I’ve tried doing it using 2 approaches: UiPath activities + Invoke VBA for the Excel specific operations. UiPath activities against Data Tables. I’ve realized that the 2nd approach is 6-7 times slower, so I think the 1st one is the best option if you pursue performance. But what about best practices? Is there any recommendation against the ma…

In relation to the thread above, I am prompted to ask

_ **if there are other ways that UiPath performance could speed up during datatable looping.** _

For illustration purpose,

1. I am attaching two projects that both generate numbers from 1 to 99999.  
[LoopPerformanceIssue.zip](https://forum.uipath.com/uploads/short-url/msMm0RfShgZfDUC35tYz7mK1el1.zip) (37.6 KB)

> - ByMacro → Executes a macro to generate the numbers.
> - ByUiPath → Simply performs Add DataRow to DT then saves to excel.
> 
> _Execution Time_
> 
> - ByMacro → 1.19 min
> - ByUiPath → almost 1hr

1. Tasks like renaming and moving files have the performance result.  
(no WF attached. 😅)

> No. of files to rename/move from one folder to another: 38000
> 
> - In UiPath → 7.25hrs
> - In Macro → 35min

I know there is nothing wrong with using Macro,  
but there are clients who want to purely use UiPath for implementation.  
(especially for environments without Microsoft Office)

What approach do you suggest?  
Thanks in advance!

Sorry for the long post. 🙇‍♀️

---

<div class="post-metadata">

**Author:** ![indrajit.shah](https://avatars.discourse-cdn.com/v4/letter/i/3da27b/32.png) [@indrajit.shah](https://forum.uipath.com/u/indrajit.shah)\
**Post date:** [January 24, 2020, 10:43am UTC](https://forum.uipath.com/t/uipath-datatable-loop-performance-issue/187994/2 "2020-01-24T10:43:46Z")

</div>

I executed the same attached code, it took 35sec for macro and 5sec for UiPath

instead of excel scope you can use **Read Range from Workbook** , it doesn’t required MS Office

![image](https://global.discourse-cdn.com/uipath/original/3X/b/0/b0c8a58e20c6357bd4f2ff35d7ea3a2abc94eb60.png)

---

<div class="post-metadata">

**Author:** ![frueda](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/frueda/32/113323_2.png) [@frueda](https://forum.uipath.com/u/frueda)\
**Post date:** [January 25, 2020, 10:05pm UTC](https://forum.uipath.com/t/uipath-datatable-loop-performance-issue/187994/3 "2020-01-25T22:05:12Z")

</div>

Other than what @indrajit.shah has already said, I finally used pure UIPath, with _Invoke Code_ activities wherever the complexity was high (like adding columns or rows in a specific position, complex loops, building HTML messages and so on). Not so quick like VBA macros, but way faster than UIPath activities doing the same.

---

<div class="post-metadata">

**Author:** ![marci080](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marci080/32/54713_2.png) [@marci080](https://forum.uipath.com/u/marci080)\
**Post date:** [January 27, 2020, 1:28am UTC](https://forum.uipath.com/t/uipath-datatable-loop-performance-issue/187994/4 "2020-01-27T01:28:07Z")

</div>

Hi @indrajit.shah

Thank you so much for the suggestion.  
I changed the activity to Write Range from Workbook,  
but it did not have significant change in speed.

Is it possibly because of my PC specs?  
I have 8G RAM and i3-7130U CPU @2.70 GHz (4CPUs), ~2.7GHz Processor.  
May I know yours?

---

<div class="post-metadata">

**Author:** ![indrajit.shah](https://avatars.discourse-cdn.com/v4/letter/i/3da27b/32.png) [@indrajit.shah](https://forum.uipath.com/u/indrajit.shah)\
**Post date:** [January 27, 2020, 7:28am UTC](https://forum.uipath.com/t/uipath-datatable-loop-performance-issue/187994/5 "2020-01-27T07:28:43Z")

</div>

![image](https://global.discourse-cdn.com/uipath/original/3X/8/a/8a726ae1de9251328acfc8d4ba7eac4c46cf90e1.png)

---

<div class="post-metadata">

**Author:** ![aeklof](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@aeklof](https://forum.uipath.com/u/aeklof)\
**Post date:** [January 27, 2020, 8:28am UTC](https://forum.uipath.com/t/uipath-datatable-loop-performance-issue/187994/6 "2020-01-27T08:28:58Z")

</div>

Did you try executing the code in both debug and run mode? In debug mode the compiler won’t optimize the code which will make it run alot slower.

---

<div class="post-metadata">

**Author:** ![marci080](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marci080/32/54713_2.png) [@marci080](https://forum.uipath.com/u/marci080)\
**Post date:** [January 28, 2020, 12:21am UTC](https://forum.uipath.com/t/uipath-datatable-loop-performance-issue/187994/7 "2020-01-28T00:21:12Z")

</div>

Hi @aeklof

Though I could have sworn I ran them in run mode before (around last year).  
But now when I ran them in run mode, it was indeed fast! 🥴 🤦‍♀️

I will try to perform operations inside the loop, like moving files to see its performance.

P.S. You’re a great addition to the community! Welcome to the forum!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [August 30, 2021, 12:58am UTC](https://forum.uipath.com/t/uipath-datatable-loop-performance-issue/187994/8 "2021-08-30T00:58:22Z")

</div>

Closed on August 30, 2021, 12:58am UTC

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