Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grayscale in Excel 2003

Status
Not open for further replies.

jasonp45

Programmer
Aug 23, 2001
212
US
I am trying to shade cells with grayscale based upon some data. So, if in my VB.net program my variable has a value of 10%, I want to shade a particular cell at 10% grayscale in an Excel file. My values will range from 0% to 100%.

I can create and connect to an Excel file fine, and I can change the color of a cell, but I can't figure out how to adjust the grayscale. Thanks!
 
Have you tried the excel's macro recorder ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yes, tried the macro recorder. But the object-model it's using doesn't seem to offer the functionality I'm looking for ('Interior' object).
 
You can create a gray-scale using the RGB function.
ActiveCell.Interior.Color=RGB(192,192,192) '25% gray
All three parameters should be equal (otherwise it has a tinge of color).

Here are the RGB parameters for gray-scale from the Format...Cells...Patterns menu item
0 100% gray (black)
51 80% gray
128 50%
150 40%
192 25%
256 0% white

Excel displays everything over 223 as white. And 223 looks just like 25% gray scale.

One way to simulate lighter shades of gray is to choose a pattern with white as one color and 25% gray as the other. You will see noticeable half-toning on the screen, but a color printer might be able to do better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top