VB code for conditional formatting on live value cell?

slimimi

Well-known Member
Joined
May 27, 2008
Messages
532
Hi there,\

Sorry for my long Title description - hope i got it right !! :)

Is there a way to look at a cell's own value and then format it accordingly using VB?

eg,

I have a cell whose value changes based on DDE link to live price data.
Cell is "Q5".

When the new value is greater than the old value - i want to format the pattern color of the cell.

When the new value is less than the old value - i want to format the pattern color of the cell.

Does anyone know how to do this please or is there a way to do this using spreadsheet formulas as oppose to VB?

THanks in advance for looking in..
 
Can you send me your workbook?

tstom@fuse.net

Did you run the code I posted in my previous reply?
Code:
Friend Sub OnLinkUpdate(LinkIndex As Integer)
    On Error GoTo ErrOnLinkUpdate
    If LinkRanges(LinkIndex).Value > PreviousLinkRangeValues(LinkIndex) Then
         LinkRanges(LinkIndex).Offset(, -18).Interior.Color = vbRed
    ElseIf LinkRanges(LinkIndex).Value < PreviousLinkRangeValues(LinkIndex) Then
        LinkRanges(LinkIndex).Offset(, -18).Interior.Color = vbBlue
    End If
    PreviousLinkRangeValues(LinkIndex) = LinkRanges(LinkIndex).Value
ErrOnLinkUpdate:
End Sub

The names of the links in your cells and the name Excel gives it do not always match. This snippet will tell us what Excel has named your links. If they are different, we will need to edit the link names in the setlinkondata example...
 
Last edited by a moderator:
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,215,540
Messages
6,125,405
Members
449,223
Latest member
Narrian

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top