colorindex = xlnone : color = ???

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi, gurus,

simple problem ???
when running this code, you get twice the same msgbox
BUT
the activecell turns white instead of staying "without color"
what's the problem ?
Code:
With ActiveCell.Interior
.ColorIndex = xlNone
MsgBox .Color
.Color = .Color
MsgBox .Color
End With

in other words what's the "color" equivalent for
ColorIndex = xlNone
Color = ???

kind regards,
Erik
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Eric

It is strange though,

If you test like

color=vbwhite

then you will get msgb box telling 16777215, which is exactly the same as
colorindex=xlnone

????
 
Upvote 0
As the constants are all translated to index values anyway, that should be the return value, should it not? I think I'm missing something.. because there is no color equivelant to xlNone, just an index number.
 
Upvote 0
thank you for your contributions, jindon (long time ago in same thread :-) ) and firefytr!

so, you don't know a solution ?

in fact the main problem was someone telling me he couldn't get Interior.ColorIndex to work in Excel97
so I was trying Color instead

do you know if Excel97 supports ColorIndex ?
it would surprise me if not
 
Upvote 0
Erik - -

There is a difference between Color and ColorIndex.

ColorIndex for no color is 0 or -4142.

Computers do not care about Excel's ColorIndex property in the VBA environment that is familiar to us. That ColorIndex property is a neat and tidy way Microsoft got around the color issue, by providing us with only 56 colors to choose from in the pallette at any one time.

What computers really care about is Color, specifically, the combination of Red, Green, and Blue (RGB) numerical combinations that comprise one of 16777215 colors.

The valid range for a normal RGB color is 0 to 16,777,215. The valid "high end" of each RGB factor is 256. If you multiply 256*256*256, that equals 16777216, which is a number greater by 1 than the 16777215 gotten by your code and therefore exceeds the valid RGB range. To computers, white and nothing share the same RGB and hex values (255, 255, 255 and #FFFFFF#FFFFFF respectively). That is why in your code, a theoretical "nothing" means the same as an actual "least amount of something" to the computer. Because the least amount of something is still more than nothing, the "something" is executed, that being in this case, the color white as our eyes see it in the active cell of your code.

Even revising your code to try to force the RGB's high end of 256 per component will not work because the computer will not allow it; the result will still be white:

With ActiveCell.Interior
.Color = RGB(256, 256, 256)
MsgBox .Color
.Color = .Color
MsgBox .Color
End With


As you might imagine, all these numbers are not coincidental. You may recognize the product of 256*256*256 (16777216) as being the same as the product of rows and columns (256*65536) for count of cells on a worksheet. Computers deal with bytes and base 10 factors that co-exist to help provide the working environment and calculation capabilities that we use in these programs. In this case, the calculation capabilities are RGB values, max of 16777215.
 
Upvote 0
Tom, thank you !

very intresting
nice proof why it was impossible to find "transparant Color"

kind regards,
Erik
 
Upvote 0
I may be missing something here, there are 256 values for each of the R,G,B values. (0-255). So VBA does allow all 256 values, because one of the values is 0.
 
Upvote 0

Forum statistics

Threads
1,226,699
Messages
6,192,518
Members
453,731
Latest member
Qiaoyu

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