When Ui Reads a blank Excel Cell, Exception thrown every time

excel
activities
exception

#1

I have an excel file, which has 2 Columns, and may sometimes have 5 rows of data or 25.

I am reading each cell 1 at a time using ‘read Cell’ function, and assigning to an appropriate variable, (idItem1, idItem2, etc) going top to bottom for Column A.
I can use that variable, (which is generic) later on with no issue if there is something in the corresponding cell. In fact I’m writing them all to an array and writing an individual message box for each item in the array to be sure I can play with the variable and I can get 5 results…

However, if it reads a cell that is blank it is throwing an exception and I can’t do a thing about it. I’ve tried giving the variable a default value but it still throws the following exception.

I need help getting around this…
Am I even going about this correctly? ; blindly reading every A1-A25 and then going from there to see if the variable has anything I can use? Or is there a way I can only have it recognize and only read the cells that have something in them?

I’m about 20% of the way through the UiAcademy, I’ve gone through the excel and data manipulation modules and I can’t figure this out.

I’ve tried an If box with conditions like, If “item.ToString.Contains” then proceed otherwise do nothing but whenever I run this I get an exception at the end.
Sorry if this is really long, I’m trying to be detailed. I’d really appreciate some help. Thanks so much.


#2

May be item = Nothing should work.

Why are you reading cell by cell than performing read range and then use for each row?

Row(0) should get your cell value


#3

I’m not sure I understand what you mean, but it sounds like you’re heading in the right direction… can you please elaborate?


#4

Use read range activity to read the spread sheet existent rows. The output is a datatable.

You can use “for each row” to iterate your datatable rows.

To get first 1st column value use row(0) for second column row(1) and so on.

To check if column is empty check row(0) = Nothing in if condition.

Hope it helps.