How to Offset Excel Ranges using VB.NET / C#
The following code gives you a better insight into offsetting a range using C#. The code uses get_Offset method to Offset the range
private void MathTableExample()
{
Microsoft.Office.Interop.Excel.Range oRng;
oRng = Globals.ThisAddIn.Application.get_Range("A1");
for (int i = 1; i <= 10; i++)
{
// Uses Offset Method of Excel
oRng.get_Offset(i, 0).Value2 = "9 x " + i.ToString() + " = " + (i * 9).ToString();
}
}
No comments:
Post a Comment