PDA

View Full Version : Graduated Cell Colour in Excel 2003



Gusty
01-28-2010, 05:24 AM
Hi there

is it poss to have graduated cell colours in the 2003 version. I know excel 2007 has this function but dont know how to get it in 2003. Any ideas anyone?

stanleydgrom
01-28-2010, 08:55 AM
Gusty,

I hope this is what you are looking for.

The following code will produce a list in range A1:B49, of the Interior.ColorIndex values and colors.


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Adding the Macro
1. Copy the below macro, by highlighting the macro code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.





Option Explicit
Sub RunColorIndex()
' jim may
' http://www.mrexcel.com/forum/showthread.php?t=321553
' Modified by stanleydgromjr
Dim i% 'As Integer
With Range("A1:B1")
.Value = Array("Interior.ColorIndex", "Color")
.HorizontalAlignment = xlCenter
End With
Range("A2").Select
For i% = 1 To 48
With ActiveCell
.Value = i%
.HorizontalAlignment = xlCenter
End With
With ActiveCell.Offset(, 1)
.Interior.ColorIndex = i%
.Value = i%
.HorizontalAlignment = xlCenter
End With
ActiveCell.Offset(1).Select
Next i
Range("A1:B1").ColumnWidth = 16
End Sub




Then run the "RunColorIndex" macro.

Gusty
01-28-2010, 09:31 AM
Hii there sorry for being a bit thick ... the macro has brought up a list of colours in rows 1 to 49 which is great. Now what do i do with them! No rude suggestions please. This one is for my wife who cant get access to this forum as she works for the national health service! So im abit stuck in the middle if you know what I mean.

many thanks

stanleydgrom
01-28-2010, 01:14 PM
Gusty,


Now what do i do with them!

I am not sure.

Please explain in detail your requirnents.

mdmackillop
01-29-2010, 02:27 AM
I think what is required is graduated colouring as can be used in a drawn rectangle. I don't believe that is possible in a cell. You could make a rectangle to suit a cell size, but that will obscure any text.

Gusty
01-29-2010, 03:34 AM
Thanks for all that - I will give up I think and ask the NHS to upgrade to Excel 2007!