Posted 8 September 2017, 1:47 pm EST
I currently am experimenting with GetSelection and CellRanges in C#. I want to be able to take the CellRange object, and be able to do some sort of foreach loop through it. Is this possible? Currently the only way I can loop through to get each individual cell is this:
cr = spdSht.Sheets.GetSelections();
for (int i = 0; i < cr.Count(); i++)
for (int j = cr[ i].Row; j < cr[ i].Row + cr[ i].RowCount; j++)
for (int k = cr[ i].Column; k < cr[ i].Column + cr[ i].ColumnCount; k++)
It seems like my solution is clunky. I am hoping there is some sort of better way. E.g. a Cellrange returns a collection of cells I can foreach loop through. Any guidance would be greatly appreciated!