# Write Range: two datatable to one Excel

**URL:** <https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950>\
**Category:** Help\
**Tags:** question, activities, excel\
**Created:** [September 16, 2021, 6:44am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950 "2021-09-16T06:44:46Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Astor](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/astor/32/183035_2.png) [@Astor](https://forum.uipath.com/u/Astor)\
**Post date:** [September 16, 2021, 6:44am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/1 "2021-09-16T06:44:46Z")

</div>

Hi,

I need write two different data table to one Excel file. For now, I am using write range activity and give two different starting cell parameter (one started from A6, another started form J6), but the second data table will overwrite the first one.

Could anyone provide other solution? Thank you.

---

<div class="post-metadata">

**Author:** ![NIVED\_NAMBIAR](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nived_nambiar/32/169066_2.png) [@NIVED\_NAMBIAR](https://forum.uipath.com/u/NIVED_NAMBIAR)\
**Post date:** [September 16, 2021, 6:48am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/2 "2021-09-16T06:48:25Z")

</div>

Did u use the append range activity for the second datatable

---

<div class="post-metadata">

**Author:** ![Astor](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/astor/32/183035_2.png) [@Astor](https://forum.uipath.com/u/Astor)\
**Post date:** [September 16, 2021, 6:54am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/3 "2021-09-16T06:54:48Z")

</div>

Hi,

No, because I need write two data tables side by side, both of them should started form 6th row.

---

<div class="post-metadata">

**Author:** ![prasath\_S](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath_s/32/290219_2.png) [@prasath\_S](https://forum.uipath.com/u/prasath_S)\
**Post date:** [September 16, 2021, 6:57am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/4 "2021-09-16T06:57:26Z")

</div>

Hi @Astor

I have used like this sometime back and it didn’t overwrite for me,have use tried write range under workbook instead of using write range under excel.

Thanks

---

<div class="post-metadata">

**Author:** ![Palaniyappan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/palaniyappan/32/524095_2.png) [@Palaniyappan](https://forum.uipath.com/u/Palaniyappan)\
**Post date:** [September 16, 2021, 6:59am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/5 "2021-09-16T06:59:49Z")

</div>

Hi

Welcome back to UiPath forum

> [@Astor](#):
>
> two different data table to one Excel file. For now, I am using write range activity and give two different starting cell parameter (one started from A6, another started form J6), but the second data table will overwrite the first one.

It won’t overwrite  
**The reason is you have any how specified the cell start like A6 and J6  
But make sure that you don’t have more than J with first datatable  
Only then it will overwrite the next time when you are writing from J6**  
So it should be fine

And we can do this with simple WRITE RANGE activity itself

Cheers @Astor

---

<div class="post-metadata">

**Author:** ![Gopal\_Tewari1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gopal_tewari1/32/183305_2.png) [@Gopal\_Tewari1](https://forum.uipath.com/u/Gopal_Tewari1)\
**Post date:** [September 16, 2021, 7:00am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/6 "2021-09-16T07:00:02Z")

</div>

Hi @Astor

It should work if you have only 9 columns in the first data table because if you have more than 9 columns in a first data table that comes under J6 also and if again you try to write the data using the second data table from J6 it will over right only those data of first data table which comes under J6 column.

So try to look at your column of the first data table and then create a dynamic range for your Second data table to write  
Thanks

---

<div class="post-metadata">

**Author:** ![Astor](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/astor/32/183035_2.png) [@Astor](https://forum.uipath.com/u/Astor)\
**Post date:** [September 16, 2021, 7:25am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/7 "2021-09-16T07:25:19Z")

</div>

Hi @Palaniyappan@Gopal_Tewari1,

Both of them only have 3 columns, and actually I have already created dynamic range for both data table to write. In my case, the second data table always overwrite the first one (which is on the left side of Excel).  
I have set a break point when first data table was written. It looks fine, but after continue write second data table and open the file again, a part of left side, which is the first data table’s content, is gone.

For example, If dt 1 contains 30 rows and dt 2 contains 15 rows, after write range dt 2, the 1st row ~ 15th row of dt 1 will be disappear.

---

<div class="post-metadata">

**Author:** ![Astor](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/astor/32/183035_2.png) [@Astor](https://forum.uipath.com/u/Astor)\
**Post date:** [September 16, 2021, 7:26am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/8 "2021-09-16T07:26:39Z")

</div>

Hi @prasath_S ,

Yes, I am using write range under workbook, but still have same situation. Thank you.

---

<div class="post-metadata">

**Author:** ![Gopal\_Tewari1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gopal_tewari1/32/183305_2.png) [@Gopal\_Tewari1](https://forum.uipath.com/u/Gopal_Tewari1)\
**Post date:** [September 16, 2021, 7:35am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/9 "2021-09-16T07:35:57Z")

</div>

Hi @Astor  
If possible could you please share the sample files with us as i am able to simulate your scenario and its working fine for me .  
Please find the attached screen shot  
**Dt2**  
 ![image](https://global.discourse-cdn.com/uipath/original/3X/c/5/c5ffd7359ad88db2af0fd0c4f72fbe4eeb8ca10b.png)

**DT1**  
 ![image](https://global.discourse-cdn.com/uipath/original/3X/a/7/a7529e9ae4b1f4a88c814e215cbdb11cc198747e.png)

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

Final result

 ![image](https://global.discourse-cdn.com/uipath/original/3X/3/6/3692d9800e44972b48fc62ce37b1a090f2367d33.png)

---

<div class="post-metadata">

**Author:** ![Palaniyappan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/palaniyappan/32/524095_2.png) [@Palaniyappan](https://forum.uipath.com/u/Palaniyappan)\
**Post date:** [September 16, 2021, 8:06am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/10 "2021-09-16T08:06:19Z")

</div>

> [@Astor](#):
>
> For example, If dt 1 contains 30 rows and dt 2 contains 15 rows, after write range dt 2, the 1st row ~ 15th row of dt 1 will be disappear.

Fine

Let’s take like you have two datatable named dt1 and dt2

Now dt1 has five rows and three columns  
And dt2 has seven rows and five columns

Let’s take like it is keep changing

1. Use a assign activity like this

dt1\_colcount = dt1.Columns.Count

Where dt1\_colcount is a int32 variable

1. Same for dt2 like this  
dt2\_colcount = dt2.Columns.Count

2. Now use a WRITE RANGE activity and mention the input as dt1 and cell range as  
“A1”

3. And for dt2 use another write range and mention dt2 as input and cell range as

**Convert.ToChar(65+dt2\_colcount).Tostring+(“1”).ToString**

This will write dt2 from very last column of dt1  
As we have mentioned the start cell range with column count

Hope this would help you resolve this  
Cheers @Astor

---

<div class="post-metadata">

**Author:** ![Astor](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/astor/32/183035_2.png) [@Astor](https://forum.uipath.com/u/Astor)\
**Post date:** [September 16, 2021, 8:21am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/11 "2021-09-16T08:21:25Z")

</div>

Hi, @prasath_S , @Gopal_Tewari1 , @Palaniyappan

I finally tried to change activity from write range “under workbook” to “under excel”, and… it works…  
It still confuse me, I even did not modify any parameter… but, finally, I can move to next step. Thank you for your time and kindly reply.

---

<div class="post-metadata">

**Author:** ![prasath\_S](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath_s/32/290219_2.png) [@prasath\_S](https://forum.uipath.com/u/prasath_S)\
**Post date:** [September 16, 2021, 9:01am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/12 "2021-09-16T09:01:53Z")

</div>

@Astor glad your issue resolved, please mark the appropriate topic as solution and close the thread so it may be useful to others in the future.

Thanks

---

<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:** [September 24, 2021, 6:34am UTC](https://forum.uipath.com/t/write-range-two-datatable-to-one-excel/345950/13 "2021-09-24T06:34:44Z")

</div>

Closed on September 24, 2021, 6:34am UTC

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