Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: macros

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Regina, Canada
    Posts
    79
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    is there a way to associate a number with a color?
    for example:
    when the number 1 is pressed, the cell color becoms yellow, when a 2 is pressed the cell becomes pink?

    [ This Message was edited by: Tyre on 2002-03-13 05:35 ]

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    The following should work OK, paste it into the worksheet, it turns the font colour white, unless the cell colour is white, adapt as necessary :-

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)

    If Target.Count > 1 Then Exit Sub
    If Not IsNumeric(Target.Value) Then Exit Sub

    Select Case Target.Value
    Case 1 To 56
    Target.Interior.ColorIndex = Target.Value
    If Target.Value <> 2 Then _
    Target.Font.ColorIndex = 2
    End Select

    End Sub

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Regina, Canada
    Posts
    79
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    couldn't make the macro work, ended up using Conditional Formatting
    thanks

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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