All,
I have an issue with Excel 2010 spontaneously changing coloring of some cells. I have a simple VBA macro which creates and populates sheets in a new workbook, copying all formatting information from the original workbook. Occasionally the formatting gets changed while the macro is running, but spontaneous color changes occur also sometimes when I am manually copy-pasting cells in the new workbook.
All cells have been formatted using styles. The style definition does not change, and the spontaneously changed cell still contains the style information. Only the background color of the cell changes. Conditional formats are not used. The colors that appear are typically light yellow, gold, or red - it would appear that e.g. the blue in the RGB gets zeroed out. After the colors have spontaneously changed, they can obviously be manually restored (which is not what I prefer to do).
The code to copy the cell formats is very simple, and most of the time it works without any issues. Sws refers to the source worksheet, Tws refers to the target worksheet. Values are populated prior to pasting the cell format. After this, the macro continues by entering certain regular and array formulas to individual cells using Tws.Cells(x,y).FormulaR1C1 = "Formula definition" and Tws.Cells(x,y).FormulaArray = "Array formula definition".
I suspect this behavior is an Excel bug, but I have not been able to locate any information about such a problem.
I have an issue with Excel 2010 spontaneously changing coloring of some cells. I have a simple VBA macro which creates and populates sheets in a new workbook, copying all formatting information from the original workbook. Occasionally the formatting gets changed while the macro is running, but spontaneous color changes occur also sometimes when I am manually copy-pasting cells in the new workbook.
All cells have been formatted using styles. The style definition does not change, and the spontaneously changed cell still contains the style information. Only the background color of the cell changes. Conditional formats are not used. The colors that appear are typically light yellow, gold, or red - it would appear that e.g. the blue in the RGB gets zeroed out. After the colors have spontaneously changed, they can obviously be manually restored (which is not what I prefer to do).
The code to copy the cell formats is very simple, and most of the time it works without any issues. Sws refers to the source worksheet, Tws refers to the target worksheet. Values are populated prior to pasting the cell format. After this, the macro continues by entering certain regular and array formulas to individual cells using Tws.Cells(x,y).FormulaR1C1 = "Formula definition" and Tws.Cells(x,y).FormulaArray = "Array formula definition".
Code:
Sws.Cells.Copy
Tws.Cells(1, 1).PasteSpecial xlPasteFormats
Tws.Cells(1, 1).PasteSpecial xlPasteColumnWidths