Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
carl
 
Posts: n/a
Default Macro To Change Cell Color When Value Changes

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.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JE McGimpsey
 
Posts: n/a
Default Macro To Change Cell Color When Value Changes

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.

  #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.


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JE McGimpsey
 
Posts: n/a
Default Macro To Change Cell Color When Value Changes

Yes, that makes a difference - Worksheet_Change() only fires when a
cell's value is changed manually or via link.

Hard to tell what to change without knowing how your data is input...

In article ,
carl wrote:

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

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

Thank you again. The price data in ColB is coming from a "DDE Link". This is
a "formula" that reads in streaming data from a data source.

Does that clarify ?

"JE McGimpsey" wrote:

Yes, that makes a difference - Worksheet_Change() only fires when a
cell's value is changed manually or via link.

Hard to tell what to change without knowing how your data is input...

In article ,
carl wrote:

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run a macro in a locked cell Ray Excel Discussion (Misc queries) 8 January 10th 06 01:02 AM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
macro help thephoenix12 Excel Discussion (Misc queries) 4 July 15th 05 05:57 PM
Cell Change Color - Need Help alani New Users to Excel 3 June 29th 05 03:50 PM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM


All times are GMT +1. The time now is 06:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"