Colorindex 2 vs -4142

chuckf201

New Member
Joined
Nov 28, 2011
Messages
28
I'm using Excel 2016 and I'm using VBA to get the colorindex of cells using
LeftColorIndex = wshScores.Range("D" & lRow).Offset(0, -1).Interior.ColorIndex
in a "for loop".
The sheet is set to not show grids.
Some blank cells return colorindex=2 and other show colorindex = -4142.
Visually they're 'white' but am I missing something.
What is the difference?

Thanks
Chuck
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi ,

Because you have the grid lines turned off , the difference is not apparent.

If the grid lines were turned on , you would see that the cell which returned the value of 2 for the colorindex , would be missing the grid lines.

2 is returned by the ColorIndex property when a cell has been formatted with a background color of white.

-4142 , which is the value of the VBA constant xlNone , is the value returned when a cell has no color formatting i.e. if a cell has not been formatted for any color. Visually this will be the same color as a cell which has been formatted with a background color of white.
 
Upvote 0

Forum statistics

Threads
1,215,463
Messages
6,124,963
Members
449,200
Latest member
indiansth

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