I have virtually no experience manipulating Excel from VB.NET, so consider me a total beginner.

I'm looping through cells in sheets in workbooks in a directory. I'm fine doing this if I know how many columns (which I always know) and rows (which I never know) I need to loop through.

What I need to do is loop through rows until I find a Border - i.e. if I'm on a row that has a Border on the top then stop. I don't want to loop through any more rows.

Currently I'm simply looping like this and frankly don't know where to go from here.

How can I loop through my rows until I find a border? How shall my loop look? Thanks!
vb.net Code:
  1. For i As Integer = 2 To 5 ' How many rows starting at row 2? Who knows?
  2.     For j As Integer = 1 To 10 Step 1 ' Always this many columns.
  3.         toSheet.Cells(i, j) = fromSheet.Cells(i, j + 1)
  4.     Next j
  5. Next i