Consulting

Results 1 to 6 of 6

Thread: Graduated Cell Colour in Excel 2003

  1. #1
    VBAX Regular
    Joined
    Nov 2007
    Location
    Liverpool
    Posts
    13
    Location

    Talking Graduated Cell Colour in Excel 2003

    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?

  2. #2
    VBAX Tutor
    Joined
    Nov 2006
    Location
    North East Pennsylvania, USA
    Posts
    203
    Location
    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.

  3. #3
    VBAX Regular
    Joined
    Nov 2007
    Location
    Liverpool
    Posts
    13
    Location
    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

  4. #4
    VBAX Tutor
    Joined
    Nov 2006
    Location
    North East Pennsylvania, USA
    Posts
    203
    Location
    Gusty,

    Now what do i do with them!
    I am not sure.

    Please explain in detail your requirnents.
    Last edited by stanleydgrom; 01-28-2010 at 01:52 PM.

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    VBAX Regular
    Joined
    Nov 2007
    Location
    Liverpool
    Posts
    13
    Location
    Thanks for all that - I will give up I think and ask the NHS to upgrade to Excel 2007!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •