Excel spontaneously changing colors of individual cells

FinnCoder

New Member
Joined
Aug 11, 2009
Messages
4
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".

Code:
    Sws.Cells.Copy
    Tws.Cells(1, 1).PasteSpecial xlPasteFormats
    Tws.Cells(1, 1).PasteSpecial xlPasteColumnWidths
I suspect this behavior is an Excel bug, but I have not been able to locate any information about such a problem.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,215,980
Messages
6,128,075
Members
449,418
Latest member
arm56

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top