3

How can I move to the next row in Excel using C#. I'm using Office PIA v 14. When I used Range.Next property, it takes me to the cell immediately right to the range. How can I move to the next row? ie. the cell immediately below.

rgshenoy
  • 386
  • 1
  • 4
  • 18

2 Answers2

3

Range.Next returns a Range object that represents the next cell.

I'm not really the greatest expert alive but according to the documentation you should use Offset instead. http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.offset

Here is some pseudo code

var excelApp = this.Application;
int skipRows = 1;
int skipCells = 0;
var nextRange = excelApp.ActiveCell.Offset[skipRows, skipCells].Select();
Eric Herlitz
  • 25,354
  • 27
  • 113
  • 157
1

Try the following code:

Range oRng = ws.get_Range(Column + (row +1), Type.Missing);

where ws is the worksheet object.

Sangram Nandkhile
  • 17,634
  • 19
  • 82
  • 116
Rohit Agrawal
  • 483
  • 3
  • 12