[ACCEPTED]-Iterating through an Excel range-excel
Accepted answer
Since you are already getting the Range 5 object in your event handler, you don't 4 want to re-query the worksheet for your 3 range--you won't get the new values.
Instead, try 2 looping through the Range.Cells property, like 1 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 1 is:
for (int i = 1; i <= Target.Count; i++)
{
Excel.Range r = (Excel.Range)Target.Item[i];
MessageBox.Show(Convert.ToString(r.Value2));
}
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.