Error in Excel Write Range: The range does not exist, occurs after for loop

Hello,

I am a new UIPath user and I am trying to write a datatable into Excel after running it through a for loop for filtering purposes. However, when I try to write the datatable into Excel I get the following error: The range does not exist.

After browsing through the forum and searching for the issue on the net I could not find a solution. So far I have tried toggling the “Add headers” option, changing the position of Write Range and experimenting with another datatable (which worked without a problem). I have added the screenshot of the error message and the .xaml file to this post. I would appreciate it if you could guide me in the right direction.


Here are the link for the .xaml code: XAML file or File itself

Hey @Ongun

For now this attached sample will work :slight_smile:
main (1).xaml (18.7 KB)

Will get back to you Tomorrow morning if will get some time the reason with Excel package how it is dealing here with Datatable in above case :slight_smile:.

Regards…!!
Aksh

Thanks for the prompt answer I will try it asap. By the way I will appreciate it if you can point out the reason.

Hey @Ongun

The above sample by me will work and it is working for me.
The Problem is with Excel Scope Activity for now in this particular case but on the other hand if you will use Workbook Read Range Activity it will sort out the problem for you.

Your problem is not big for now. as you mentioned other datatable it is working and i can see datatable is having one row.

The problem might be a column names in your datatable how they are seem to.
more can say on the issue when i will look into this.

Regards…!!
Aksh

Okay thanks for the explanation. As far as I tried on my system your solution works perfectly fine, yet it does not write the datatable when Write Range (from Excel activities) is used inside an Excel Scope Activity as you said.

Do you mean using Workbook Read Range activity just before using the Write Range to solve the issue?

Hi, I have the same issue, in my case, I have a big excel file, so, Workbook Read Range doesn´t works for me so I need to use Read Range within Excel Scope, then I generate two datatables and write each one using Write Range within the same Excel Scope, first one works perfect, but second doesn’t, I tried to write datatable in other file using Workbook Write Range and it works, also I tried re installing Excel packages but nothing.

Hope you can help.

Best regards

1 Like