Range.Interior.Color Different between Excel 2007 and later

I see that Range.Interior.Color returns different numbers for the same color in some cases, depending on whether it works in Excel 2007 or Excel 2010 or 2013.

Is this expected? I am surprised.

Range.Interior.Color is the background color ("Fill Color") of the cell. In the Immediate area, you can read it as follows:

? ActiveCell.Interior.Color

And install it like this:

ActiveCell.Interior.Color = 10921638

Examples:

Example 1:

(they have the same color, although their Range.Interior.Color are different.)

  • Excel 2007: 10855845
  • Excel 2010/2013: 10921638

Example 2:

  • Excel 2007: 14922893
  • Excel 2010/2013: 14857357

Example 3:

  • Excel 2007: 14211288
  • Excel 2010/2013: 14277081

? VBA- VBA7, True Excel 2010 False Excel 2007 :

#If VBA7 Then
    'Excel 2010 or later:
    Const NO_SHADING_COLOR As Long = 16777215
    Const MAIN_HEADER_COLOR As Long = 10921638 'dark gray [in xl2007 s/b 10855845]
    Const SUB_HEADER_COLOR As Long = 14857357 'light blue [in xl2007 s/b 14922893]
    Const SUBSUB_HEADER_COLOR As Long = 14277081 'medium gray [in xl2007 s/b 14211288]
#Else
    'Excel 2007 or earlier:
    Const NO_SHADING_COLOR As Long = 16777215
    Const MAIN_HEADER_COLOR As Long = 10855845 'dark gray
    Const SUB_HEADER_COLOR As Long = 14922893 'light blue
    Const SUBSUB_HEADER_COLOR As Long = 14211288 'medium gray
#End If

UPDATE:

, , RGB Range.Interior.Color RGB Range.Interior.Color. - RGB Excel, .

Range.Interior.Color , RGB. , Excel Range.Interior.Color . RGB, RGB Excel, , Range.Interior.Color .

, Excel " ". VBA . VBA GETS , .

, Application.Version, , , , . , VBA- . , - Excel VBA.

+4
4

Update:

, . Range.Interior.Color , .

FWIW, ​​ , Excel Macintosh, Windows, , , , , ( ).

0

" Excel", , "" Excels 56. , .

, , :

             Red   Green   Blue 
10855845     165     165    165
10921638     166     166    166
 9868950     150     150    150  Grey 40%

14922893     141     180    227
14857357     141     180    226
16764057     153     204    255  Pale blue

14211288     216     216    216
14277081     217     217    217
12632256     192     192    192  Grey 25%   

. , , , , . Excel .

, , - : ? ? , Microsoft Excel 2007, 2010 2013 .

Excel, , .

, 2003 2007 .

2003 56 1 56. , Excel , :

  • VBA - , Excel .
  • , .

, 2003 56 , 56 .

2003 . , , RGB (51, 51, 163), RGB (167, 167, 167). Excel, , Gray 30. , .

2007 xlsm. . RGB (167, 167, 167). ( ) , RGB (167, 167, 167), 2003 . VBA:

Colour I    Appearance   Number according      Number according
had set     on screen    to palette            to VBA
255,0,0       Red        0,0,255 Blue          255,0,0
0,0,255       Blue       255,0,0 Red           0,0,255
167,167,167   Grey 30    51,51,153 Indigo      167,167,167      Imported from 2003
167,167,167   Grey 30    167,167,167 Grey 30   167,167,167      Created with 2007

, 2007 , 2007 , .

, 2007 2010 2013 , 2003 2007 . , 2007 ​​ 2010 .

, . 2007 , RGB (167, 167, 167) . 2010 2013, , , .

, , . -. , 2007, 2010 2013 ?

+2

-, . Excel 2010 ( - ), , 3 x 8- . RGB (Red-Green-Blue) , -, BGR (Blue-Green-Red), , . , XL2003 , "", , MS , ( RGB).

0

RGB(), ,

   Activecell.Interior.Color = RGB(200,150,230)

,

    Const RED = 200
    Const GRN = 150
    Const BLU = 230
    ......
    Activecell.Interior.Color = RGB(RED, GRN, BLU)

As for “Expected?”, This is: Color = 10921638yes RGB(165, 165, 165), but Color = 10855845- RGB(166, 166, 166). I do not have access to Excel 2007 at the moment, but if your color values ​​are really system "dark gray" in both cases, then Microsoft has changed the value of "dark gray" between versions of Excel. I suspect that you do not care, and I do not see the difference between them. In any case, you can use the same color in all versions.

-1
source

All Articles