Write cell activity Object reference is not set to an instance of an object in the second iteration!

Hi all,

May I ask for some help in writing cell activity !! …

I’m really stuck !! I get these errors once is write range doesn’t exist … and another one is Object reference is not set to an instance of an object !!!

My workflow as below:

Under multiple conditions, I need to write these different statuses in a specific column called Status … So inside a loop that will enter a different status according to the conditions I need to write this status !!!

I trid with this range code >> CurrentSheet.Cell (“A”+index.ToString)

Index is a variable int = 2 as a default value and entered status will start from A2 …

So why in the first iteration is worked well !! Then if it goes to another condition make an error as I mentioned above !!!


Please any suggestions!! I will be so grateful😢

What do you mean @Rawan.md

Search for activity called write datatable to excel

Then you can just pass this write range outside the for each row

You don’t need write cell for each and every row it will consume so much time


write range doesn’t exist >> this has happened to a mistake in my range …

Anyway , I can’t use the write range outside the for each , because I need to write each row status it will be different in each iteration !!! I have to know what is the status for each row in each iteration!!

note that I use the same expression for the range in set range color activity and it works fine !!! in another hand, I couldn’t use the Write Cell Workbook activity It throw an error that said excel file is used by another process !! :slightly_frowning_face:

You are are using for each row in datatable right? @Rawan.md

Yes !

I’m using Use Excel File activity then inside it I’m using for each row in dt …

Then you can try this @Rawan.md

In assign activity

Left side - CurrentRow(“Status”)
Right side - your status value

Now the iteration happens and the status will be updated in the datatable

After looping all the rows write range the value after for each row activity and you can see the status appropriate to the rows


1 Like

Hi @Rawan.md

using increment of variable Index after write cell as below screenshot

that’s what I have already used !!!

the problem in the second iteration !!! I couldn’t understand why !!

that’s what I have already used before write cell activity …

Okay, I will give it a try and let you know.

Thanks a lot it works well :star_struck:

1 Like

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