Prova con
codice:
  if (R > (RowCount - 1)) or ( C > (ColCount - 1)) then
    Exit;