Write Range: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Hello, I’m getting this error when I try to write a new “sheet” in an excel file with some data.

Basically, What I do It’s I get data from Excel File 1 (using Read Range ) and I put it to another Excel file 2 with “Write Range” and I got this error message.

I got some values in the variable rpaValores.

I put that inside the first one Excel Process Scope and I got the same mistake.


Please, any idea? Thanks.

You didn’t fill in the Cell value.

Ok, I put “A2:B31” now but I got the same mistake.

Don’t put a range. You put a cell, which is why it says Cell in the box. Just put “A2” if that’s where you want it to start writing.

Thanks for the explanation, but I changed that to “A2” but I still get the same mistake.

Post a screenshot of all the properties of your Write Range.

Are you sure there are rows in rpaValores? Is there a sheet named test? Is the path to the Excel file correct? You have a relative path, not an absolute path.

Also, it appears you are using the Workbook Write Range, not the Excel Write Range. The Excel Write Range doesn’t have a box for the path to the file, because it goes inside a Use Excel File activity.


2.-rows? I got these values in rpaValores

3.- No, there isn’t, but I simulated this kind of workflow and It creates a new sheet called “test”. Yes, that path is correct.

4.-I can’t find Excel write range. Is it a modern activity ? Because, I need to use modern activities to this workflow.

  1. that’s what a datatable is. You have 31 rows.

  2. ok that’s fine as long as you have it set to create the sheet if it doesn’t exist (this is in the Excel activities, not workbook)

4: there are modern and classic versions, this is looking at modern. Notice there’s a Write Range under Microsoft → Office 365 → Excel, and a different one under System → File → Workbook (and this is the one you’re using). You should switch to the Excel one.


1.- I’m realizing that If I put a new excel file as the final path, It works. I’m not sure What is happening with the current Excel file that I have to work… I was thinking about negative values inside some sheets but I don’t know plus I don’t select those values…

I don’t find that activity… Could you tell me If I have to install a package?

As far as I know, both activities are in the same package: UiPath.Excel.Activities. Maybe upgrade that to a newer version. What do you see when you search Activities for Excel instead of Write Range?

Also make sure you have set your project to Modern:

Depending upon your version you may also have an Excel-specific settings page:

Hello @pprin001 - Does your excel has PIVOT tables ?

Hello, ushu. yes, It does. Is this the cause of this problem?

Hello @pprin001

You can try to write to another excel sheet and if that issue is not occuring then you need to check the excel which you are using.

As per my understanding the issue can happen if you have provided a wrong range (but you corrected that by providing the starting cell as “A2”)

Another problem can be in the particular sheet there can be pivot table created.

So better to try with another output.xlsx file and check whether its working or not.


1 Like

@pprin001 I guess so. Can you please try doing the same thing without any pivot table in your excel sheets. Have a look on the below link

1 Like