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

Hello All ,

Whenever I use any workbook activity like read range , read column , etc. I am getting error as “Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index”.

But , When I used Read range with exact same range parameters within Excel application scope , its working.
Can anybody please help.

Regards,
Akanksha

1 Like

@pakankshabha

Welcome to our UiPath community.

Could you please help me with screenshot of Workbook Read Range activity. Need to check once how you are passing data to it.

image

receiptColumn is the output of Read Column activity .

If I use same parameters (sheetname , filename , range) within excel application scope. It works

Hi @pakankshabha

I am attaching one workflow which can help you to get the difference between the Excel & Workbook activities Cell Range Property.

Just run/debug the workflow.
IncreamentMonthAsPerSerialNo.xlsx (8.8 KB)
Main.xaml (12.8 KB)

Actually Datatable value starts from 0.
And Normal Row index starts from 1.

Hope this may help to solve your issue
Mark as solution if this helps you and like it :innocent:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Thank you … In the code , I am not able to see some activity. Can you please send the screenshot how you used it.

Hi @pakankshabha

Just look for the Cell/range property in both activities

Below SS is for Write Cell Workbook Activity
image
image

Below SS is for Write Cell Excel Activity


image

Hope this may help to solve your issue
Mark as solution if this helps you and like it :innocent:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Thank you. I have tried copying the data which I need to read in some sample excel. I kept the range same. There it worked. As per my observation , this activity of workbook (Read range , read column , write range) is not working if the excel contains pivots n all. In the regular excel (without pivots) its working on the same data.

I am not sure if my observation is correct.

Hello, did you find any solution for this? I am facing the same issue and yes my excel file also has Pivot table

Hi @Pratik_Wavhal &/or anyone,

I’m a new to UiPath & I began with the “Get Started With RPA Development” course. In the 1st video tutorial I encounter the "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index.

Please see the attached screenshot. I am using the MailMessages(0) index as indicated in the tutorial. Any assistance, will be greatly appreciated.

Thanks,
Hector

2 Likes

Hey! How did you solve this issue? Thanks

Hi i have the same issue? did you find something to fix this? as a work around im migrating data sheet to another excel excluding all other sheets and pivots.

Regards

Pedro

I had the same issue. Did you figure it out? Want to move onto next tutorial, but don’t think it would be wise if I cannot figure this first issue out.

Hey did you ever figure this out? I had the same issue.

Hey did you ever get this figured out?

Not Yet, if you find something please let me know, as a work around im creating another file without pivots.

Apologies for not being available to respond earlier.

  1. Choosing the correct scope for the variable: MailMessages is what ultimately resolved
    my issue.
  2. Make sure the variable naming convention and spelling remain consistent when editing variables in different locations within Studio.

E.g., when creating a variable, the type is automatically generated depending on the selected property and this directly affects the scope. As a result, I found the managing variables link to be very helpful.

Thank you for your response. I will try to work it out.

Check Hector’s response. He just added some info that might be helpful.

1 Like

Please see my response in the UiPath Forum.