+ Reply to Thread
Results 1 to 5 of 5

how to convert number into colors?

  1. #1
    Patbil
    Guest

    how to convert number into colors?

    hello
    I want to convert a matrix of results in decimal or real number into a
    spectrum of colors (or grey scale if it's not possible) to make a "picture"
    it's quiet urgent so a great thanks to who will success the challenge!

  2. #2
    Bob Phillips
    Guest

    Re: how to convert number into colors?

    Here is one way

    Private Const xlCIBlack As Long = 1
    Private Const xlCIWhite As Long = 2
    Private Const xlCIRed As Long = 3
    Private Const xlCIBrightGreen As Long = 4
    Private Const xlCIBlue As Long = 5
    Private Const xlCIYellow As Long = 6
    Private Const xlCIPink As Long = 7
    Private Const xlCITurquoise As Long = 8
    Private Const xlCIDarkRed As Long = 9
    Private Const xlCIGreen As Long = 10
    Private Const xlCIDarkBlue As Long = 11
    Private Const xlCIDarkYellow As Long = 12
    Private Const xlCIViolet As Long = 13
    Private Const xlCITeal As Long = 14
    Private Const xlCIGray25 As Long = 15
    Private Const xlCIGray50 As Long = 16
    Private Const xlCIPeriwinkle As Long = 17
    Private Const xlCIPlum As Long = 18
    Private Const xlCIIvory As Long = 19
    Private Const xlCILightTurquoise As Long = 20
    Private Const xlCIDarkPurple As Long = 21
    Private Const xlCICoral As Long = 22
    Private Const xlCIOceanBlue As Long = 23
    Private Const xlCIIceBlue As Long = 24
    Private Const xlCISkyBlue As Long = 33
    Private Const xlCILightGreen As Long = 35
    Private Const xlCILightYellow As Long = 36
    Private Const xlCIPaleBlue As Long = 37
    Private Const xlCIRose As Long = 38
    Private Const xlCILavender As Long = 39
    Private Const xlCITan As Long = 40
    Private Const xlCILightBlue As Long = 41
    Private Const xlCIAqua As Long = 42
    Private Const xlCILime As Long = 43
    Private Const xlCIGold As Long = 44
    Private Const xlCILightOrange As Long = 45
    Private Const xlCIOrange As Long = 46
    Private Const xlCIBlueGray As Long = 47
    Private Const xlCIGray40 As Long = 48
    Private Const xlCIDarkTeal As Long = 49
    Private Const xlCISeaGreen As Long = 50
    Private Const xlCIDarkGreen As Long = 51
    Private Const xlCIBrown As Long = 53
    Private Const xlCIIndigo As Long = 55
    Private Const xlCIGray80 As Long = 56



    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cell As Range

    On Error GoTo ws_exit
    Application.EnableEvents = False
    For Each cell In Target
    Select Case cell.Value
    Case "r": cell.Interior.ColorIndex = xlCIRed
    Case "b": cell.Interior.ColorIndex = xlCIBlue
    Case "g": cell.Interior.ColorIndex = xlCIGreen
    Case "y": cell.Interior.ColorIndex = xlCIYellow
    End Select
    Next cell

    ws_exit:
    Application.EnableEvents = True

    End Sub


    This is worksheet event code, which means that it needs to be
    placed in the appropriate worksheet code module, not a standard
    code module. To do this, right-click on the sheet tab, select
    the View Code option from the menu, and paste the code in.

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "Patbil" <patbil78@wanadoo.fr> wrote in message
    news:43ebb526$0$20155$8fcfb975@news.wanadoo.fr...
    > hello
    > I want to convert a matrix of results in decimal or real number into a
    > spectrum of colors (or grey scale if it's not possible) to make a

    "picture"
    > it's quiet urgent so a great thanks to who will success the challenge!




  3. #3
    bplumhoff@gmail.com
    Guest

    Re: how to convert number into colors?

    Hi Bob,

    What about

    Private Enum xlCI: xlCIBlack = 1: xlCIWhite: xlCIRed: xlCIBrightGreen:
    xlCIBlue
    : xlCIYellow: xlCIPink: xlCITurquoise: xlCIDarkRed: xlCIGreen
    : xlCIDarkBlue: xlCIDarkYellow: xlCIViolet: xlCITeal: xlCIGray25
    : xlCIGray50: xlCIPeriwinkle: xlCIPlum: xlCIIvory: xlCILightTurquoise
    : xlCIDarkPurple: xlCICoral: xlCIOceanBlue: xlCIIceBlue
    : xlCISkyBlue = 33
    : xlCILightGreen = 35: xlCILightYellow: xlCIPaleBlue: xlCIRose:
    xlCILavender: xlCITan
    : xlCILightBlue: xlCIAqua: xlCILime: xlCIGold: xlCILightOrange
    : xlCIOrange: xlCIBlueGray: xlCIGray40: xlCIDarkTeal: xlCISeaGreen
    : xlCIDarkGreen: xlCIBrown = 53: xlCIIndigo = 55: xlCIGray80
    End Enum

    ?

    Regards,
    Bernd


  4. #4
    Bob Phillips
    Guest

    Re: how to convert number into colors?

    Hi Bernd,

    Yes you could certainly do that, but I didn't for two reasons.

    Enums have too many restrictions for my taste. If you don't assign a value,
    as you haven't in many cases, you cannot intuitively see their value, so you
    really need to assign values IMO.
    Enums are great to declare a type, but as I didn't want to use the type
    xlCI, it had no extra benefit.

    They do look good though <G>

    Bob

    <bplumhoff@gmail.com> wrote in message
    news:1139563690.282039.21660@f14g2000cwb.googlegroups.com...
    > Hi Bob,
    >
    > What about
    >
    > Private Enum xlCI: xlCIBlack = 1: xlCIWhite: xlCIRed: xlCIBrightGreen:
    > xlCIBlue
    > : xlCIYellow: xlCIPink: xlCITurquoise: xlCIDarkRed: xlCIGreen
    > : xlCIDarkBlue: xlCIDarkYellow: xlCIViolet: xlCITeal: xlCIGray25
    > : xlCIGray50: xlCIPeriwinkle: xlCIPlum: xlCIIvory: xlCILightTurquoise
    > : xlCIDarkPurple: xlCICoral: xlCIOceanBlue: xlCIIceBlue
    > : xlCISkyBlue = 33
    > : xlCILightGreen = 35: xlCILightYellow: xlCIPaleBlue: xlCIRose:
    > xlCILavender: xlCITan
    > : xlCILightBlue: xlCIAqua: xlCILime: xlCIGold: xlCILightOrange
    > : xlCIOrange: xlCIBlueGray: xlCIGray40: xlCIDarkTeal: xlCISeaGreen
    > : xlCIDarkGreen: xlCIBrown = 53: xlCIIndigo = 55: xlCIGray80
    > End Enum
    >
    > ?
    >
    > Regards,
    > Bernd
    >




  5. #5
    bplumhoff@gmail.com
    Guest

    Re: how to convert number into colors?

    Hi Bob,

    I see your point.

    But I like it <G>

    Private Enum xlCI 'Excel Color Index
    : xlCIBlack = 1: xlCIWhite: xlCIRed: xlCIBrightGreen: xlCIBlue '1 - 5
    : xlCIYellow: xlCIPink: xlCITurquoise: xlCIDarkRed: xlCIGreen '6 - 10
    : xlCIDarkBlue: xlCIDarkYellow: xlCIViolet: xlCITeal: xlCIGray25 '11 -
    15
    : xlCIGray50: xlCIPeriwinkle: xlCIPlum: xlCIIvory: xlCILightTurquoise
    '16 - 20
    : xlCIDarkPurple: xlCICoral: xlCIOceanBlue: xlCIIceBlue: xlCILightBrown
    '21 - 25
    : xlCIMagenta2: xlCIYellow2: xlCICyan2: xlCIDarkPink: xlCIDarkBrown '26
    - 30
    : xlCIDarkTurquoise: xlCISeaBlue: xlCISkyBlue: xlCILightTurquoise2:
    xlCILightGreen '31 - 35
    : xlCILightYellow: xlCIPaleBlue: xlCIRose: xlCILavender: xlCITan '36 -
    40
    : xlCILightBlue: xlCIAqua: xlCILime: xlCIGold: xlCILightOrange '41 - 45
    : xlCIOrange: xlCIBlueGray: xlCIGray40: xlCIDarkTeal: xlCISeaGreen '46
    - 50
    : xlCIDarkGreen: xlCIGreenBrown: xlCIBrown: xlCIDarkPink2: xlCIIndigo
    '51 - 55
    : xlCIGray80 '56
    End Enum

    Regards,
    Bernd


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1