cell to change color


Posted by John on July 11, 2001 5:43 PM

I'm stomped with a problem that you may have an answer to. What I wanted to happen is when a cell was clicked, that cell will either change color or it will import a graphic. Actually, my question is supposed to be "is it possible"?
Hope you can help.
Thanx.

Posted by Damon Ostrander on July 11, 2001 10:45 PM

Yes John, either can be done fairly easily using worksheet events. The SelectionChange event will "fire" when any cell is selected, and its Target argument can be used to find out it the cell selected is the one you are interested in, in which case your code can change its color or import that graphic.

Damon

Posted by Joe Was on July 12, 2001 5:30 AM

Many ways tol to change cell color

This has been on the board alot please use your search Ctrl-f before you post.

Sub myAddColor()
' Add color if Range("B12:H22") greater than 0, if 0 remove color.
' By Joe Was
'
Range("B12:H22").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="0"
Selection.FormatConditions(1).Interior.ColorIndex = 8
Range("A1").Select
End Sub

This code changes the indicated range light-blue if the cell value is greater than 0 or text. If the value is 0 the color is re-set to no-color. JSW

Macro1 Macro Macro by Joseph S. Was Ctrl-s



Posted by Joe Was on July 12, 2001 5:50 AM

Color changes with flash

Sub FlashBack()
'Make cell range Background color, flash x times, x fast, in x color,
'when Ctrl-a is pressed.

Dim newColor As Integer
Dim myCell As Range
Dim x As Integer
Dim fSpeed

'Make this cell range background flash!
Set myCell = Range("A1:A2")
Application.DisplayStatusBar = True
Application.StatusBar = "... Select Cell to Stop and Edit or Wait for Flashing to Stop! "

'Make cell background flash to this color!
'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30,
'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11,
'Gray-50% 16, Gray-25% 15, Bright Cyan 8.
newColor = 27

'Make the cell range flash fast: 0.01 to slow: 0.99
fSpeed = 0.2

'Make cell flash, this many times!
Do Until x = 35

'Run loop!
DoEvents
Start = Timer
Delay = Start + fSpeed
Do Until Timer > Delay
DoEvents
myCell.Interior.ColorIndex = newColor
Loop
Start = Timer
Delay = Start + fSpeed
Do Until Timer > Delay
DoEvents
myCell.Interior.ColorIndex = xlNone
Loop
x = x + 1
Loop
Application.StatusBar = False
Application.DisplayStatusBar = Application.DisplayStatusBar
End Sub

Sub FlashFont()
'Make cell range font flash, x times, x fast, in x color,
'when Ctrl-z is pressed.
Dim newColor As Integer
Dim myCell As Range
Dim x As Integer
Dim fSpeed

'Make this cell range font flash!
Set myCell = Range("A1:A2")
Application.DisplayStatusBar = True
Application.StatusBar = "... Select Cell to Stop and Edit or Wait for Flashing to Stop! "

'Make cell font flash to this color!
'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30,
'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11,
'Gray-50% 16, Gray-25% 15, Bright Cyan 8.

newColor = 3

'Make the cell range flash fast: 0.01 to slow: 0.99
fSpeed = 0.3

'Make cell flash, this many times!
Do Until x = 20

'Run loop!
DoEvents
Start = Timer
Delay = Start + fSpeed
Do Until Timer > Delay
DoEvents
myCell.Font.ColorIndex = newColor
Loop
Start = Timer
Delay = Start + fSpeed
Do Until Timer > Delay
DoEvents
myCell.Font.ColorIndex = xlAutomatic
Loop
x = x + 1
Loop
Application.StatusBar = False
Application.DisplayStatusBar = Application.DisplayStatusBar
End Sub
Sub reSetFlash()
'Re-set cell range color if edit break on color, Ctrl-r to re-set!
ActiveCell.Select
Selection.Interior.ColorIndex = xlNone
End Sub

Do not change the name of this macro or it will fail! Macro1 Macro Macro by Joseph S. Was Ctrl-s