![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Regina, Canada
Posts: 79
|
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 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
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 |
|
Board Regular
Join Date: Feb 2002
Location: Regina, Canada
Posts: 79
|
couldn't make the macro work, ended up using Conditional Formatting
thanks |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|