View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
carl
 
Posts: n/a
Default Macro To Change Cell Color When Value Changes

Thank you very much.

I tried this out but could not get it to work . I have a formula in ColB.
Does that make a difference ?

"JE McGimpsey" wrote:

One way:

Put this in your worksheet code module (right-click the worksheet tab
and choose View Code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const sRANGE As String = "B2:B100"
Const nCOLORINDEX As Long = 10 'Green
With Target
If .Count 1 Then Exit Sub
If Not Intersect(.Cells, Range(sRANGE)) Is Nothing Then
With .Interior
.ColorIndex = IIf(.ColorIndex = nCOLORINDEX, _
xlColorIndexNone, nCOLORINDEX)
End With
End If
End With
End Sub


In article ,
carl wrote:

I have a spreadsheet that is tracking stock prices. The cell with the price
is fed by a DDE link.


Stock Price
AIG 100
AXP 100
AMAT 100
AMGN 100
AMD 100

I am trying to create a visual monitoring tool. I was hoping to have the
cell (ColB) change color (any color will do) everytime the price changes.

For example, if the cell initially is no color, on the first change, color
switches to green, on the next change, back to no color, on the 3rd price
change, back to green etc.

Is this type of thing possible ?

Thank you in advance.