Iterating through an Excel range

Since you are already getting the Range object in your event handler, you don't want to re-query the worksheet for your range--you won't get the new values.

Instead, try looping through the Range.Cells property, like this:

foreach (Range c in Target.Cells)
{
   string changedCell = c.get_Address(Type.Missing, Type.Missing, XlReferenceStyle.xlA1, Type.Missing, Type.Missing);  
   MessageBox.Show("Address:" + changedCell + " Value: " + c.Value2);
}

To iterate the Range, it's 1-based, that is:

for (int i = 1; i <= Target.Count; i++)
{
  Excel.Range r = (Excel.Range)Target.Item[i];
  MessageBox.Show(Convert.ToString(r.Value2));
}

Tags:

C#

Excel