I am not going to follow those links while I am at work. There is very rarely a need for an "image" with problems like this - just put the data into the body of your question - it has the advantage of making it easier for us to paste into a test scenario which makes it easier for us to help you.
However, in this case I can tell you, regardless of your data, that you should start at the end of the range and work backwards.
Demonstration - imagine you have 5 rows of data
Row 1 : A
Row 2 : B
Row 3 : C
Row 4 : D
Row 5 : E
Remember, this is Excel, so Row 1, Row 2, etc is derived for you. You have no control over the row number.
Now you want to delete the rows containing 'C' and 'D' ... currently Rows 3 & 4. Result of deleting 'C' is
Row 1 : A
Row 2 : B
Row 3 : D
Row 4 : E
Note the row numbering has changed. But in your foreach loop, it still thinks that the original numbering holds (it doesn't go back and look at all the data after each deletion - that is determined up front). So the "next" row after what did hold 'C', which
was row 4, is now row 3. 'C' was on row 3, we're moving on, so your code next looks at Row 4, which contains E, and D is completely skipped over.
If you do the same thing backwards - start at row 5, delete 'D'.
Row 1 : A
Row 2 : B
Row 3 : C
Row 4 : E
The "next" row examined is still the original Row 3 - the only rows that move are ones that we have already examined and moved past.
Another point to note is that in many languages you cannot change what a
foreach
is using - i.e. the range for r is fixed. To overcome that use the row numbers instead, so my loop would look something like (untested)
for (int i=5; i>0; i--)
{
Excel.Range r = excelApp.get_Range(activeworksheet.Cells[i,1]);
if (r.Value2 > 0.0F)
{
r.EntireRow.Delete(XlDeleteShiftDirection.xlShiftUp);
}
}