Highlight cell for one second like stockmarket software

eros

Board Regular
Joined
May 6, 2011
Messages
90
Hi all,

Is there a way to highlight a cell for one second, when the cell value is updated by a vba function.

The challenge here is that the cell value is calculated in a vba function, not in a sub; therefore, direct access to the cell is not permitted, (as far as I know)

The Cell is expected to be highlighted in yellow and after a second back to normal.

Many thanks.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
If I'm understanding right:

Put this in a standard . Edit the address of the cell that you want to flash.

Code:
Function MyCell() As Range
Set MyCell = Sheets("Sheet1").Range("B3") 'Cell that will flash. Edit as required
End Function

Sub FlashMe()

With MyCell

    If .Interior.ColorIndex = 6 Then
        .Interior.ColorIndex = xlNone
    Else
        .Interior.ColorIndex = 6
    End If

End With

End Sub

Then put this in the sheet code that contains that cell

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address(0, 0) = MyCell.Address(0, 0) Then
    Call FlashMe
    
    Application.OnTime Now + TimeValue("00:00:01"), "FlashMe"
End If

End Sub

If VBA code changes the cell, the worksheet change will trigger to give a flashing cell and then return it back to blank.

Hope it helps
 
Upvote 0
Thank you very much for your prompt return @gaj104.

If the cells to highlight are in fact a 200 row by 3 column table, am I supposed to define a seperate sub for each cell in this table?

I hope, I am not...
 
Upvote 0
... Moreover, the worksheet is very busy gathering DDE data from an external server; therefore, using Worksheet_Change event could make Excel get very busy updating the sheet, I am afraid...

Sorry for not making your life easier...
 
Upvote 0
Ok, this still uses worksheet change, but uses a predefined range A1:C200 in this example. So anytime a cell is changed via the vba code it will flash if it is in that range.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim strR As String

If Not Application.Intersect(Target, Me.Range("A1:C200")) Is Nothing Then

    strR = Target.Address(0, 0)

    Call FlashMe(strR)
    Application.OnTime Now + TimeValue("00:00:01"), "'FlashMe """ & strR & """'"

End If

End Sub

Then in the standard module this is all you need.

Code:
Sub FlashMe(strR As String)

Dim myCell As Range
Set myCell = Sheets("Sheet1").Range(strR)

With myCell

    If .Interior.ColorIndex = 6 Then
        .Interior.ColorIndex = xlNone
    Else
        .Interior.ColorIndex = 6
    End If

End With

End Sub

See how it performs.
 
Upvote 0
Two questions/concerns:

1) Am I wrong to thing that Worksheet_Change event is called when a cell in a worksheet is manually changed, not when updated by a DDE link etc. All of my cell data comes from an external server with DDE links as I don't type anything manually, and I am worried if it will properly trigger the worksheet_change event.

If you think the solution to this is to use Worksheet_Calculate, I am more concerned then as I am making Excel extremely busy, getting the external data continuously, calculating it, sorting 3x200 table, putting each of 3x200 cells a trigger to check if a second has passed. I am afraid Excel would just stop responding.

2) A1:C200 in my case is an automatically-sorted table. And based on several and continuous calculations it is sorted automatically. That means a cell when highlighted by your sub being in row 55, column 3, may not reside on that specific address after 1 second - when it needs to be de-highlighted. Does not this cause any inconsistency?

Many thanks for your kind assistance.
 
Upvote 0
By the way,

I cannot try your solution before the actual market is open, therefore, your solution might be perfectly ok, but currently I am not able to test it.

I am just thinking if you could suggest a better solution considering likely performance issues I have just mentioned.
 
Upvote 0

Forum statistics

Threads
1,223,723
Messages
6,174,113
Members
452,545
Latest member
boybenqn

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