When I call Range.Copy() on a column and then call Range.Insert() before another column, it works perfectly; the original column is duplicated to where I want it. However, if I make another call to Range.Insert() without calling Range.Copy() again, it does insert a new column where I want it, but without any borders.
I find that if I do call Range.Copy() every time, the output is exactly what I want, but it takes about 5 times as long. Do I really need to do that?
Here is my code for reference:
Range sheetCols = sheet.Columns;
...
int col = routesStartCol;
foreach (RouteObject route in loc.Routes)
{
Range thisCol = sheetCols[col]; com.Got(thisCol);
if (col == routesStartCol)
thisCol.Copy();
else
thisCol.Insert(XlInsertShiftDirection.xlShiftToRight);
sheetCells[routeNameRow, col] = route.Name;
col++;
}
It looks like I really do need to copy every time. What it’s really doing when you DON’T copy is just inserting a blank column, which by default copies some of the formatting of the column to the left.