How to know if foreach loop has met the last row?

I am new in RPA, I met this kind of case. I read an excell file and do a foreach loop to the file, and then put them into 2 different DataTables based on the category. At the end, i want to execute a message box if the row number of the DataTables has met certain condition. But if the there are no more row in the excell file, I want to execute the message box even if the row number condition has not met. I can’t upload the project because I am a new user, so that I can’t upload any file. Here is my project: https://drive.google.com/drive/folders/1KKhgQZQnWK1A8Qsu-rWWVEfNljj7btjb?usp=sharing

For Each Row activity of a datatable will automatically exit once it has reach the last row.

Yes, it is the problem, but what I want is to execute the message box before it exit

Ok,

so you can get a count of the datatable using
RowCount = Datatable.Rows.Count.

then you can use Row index to compare if you have reached the last row.
RowIndex = dtOut.Rows.IndexOf(row)

If (RowCount - 1) = RowIndex

1 Like