Display and Disappear Text in Cell

EE Pros,

I am looking for some help in building a macro that does something very simple.  It posts a text confirmation in a cell, to be displayed for 4 seconds, black text, yellow fill, then disappear.  I plan to call the sub from other routines at the end as a confirmation of the sub being completed.

I have mocked up a sample for you.

Thank you in advance......

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Neil FlemingConsultant and developerCommented:
I'd use the "Timer" function for this. Try the following:

Option Explicit

Sub testflash()
'routine to test the flashtext routine below:
flashText "test", Range("c5"), 4

End Sub

Sub flashText(sText As String, rShow As Range, iShowFor As Long)
Dim iOff As Long
'set the off time. the built-in Timer gives the number of seconds since midnight
iOff = Timer + iShowFor
rShow.Interior.Color = RGB(255, 255, 0)
rShow = sText

'loop till the specified number of seconds has passed
Loop Until Timer > iOff
rShow.Interior.Color = RGB(255, 255, 255)
rShow = ""

End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bright01Author Commented:
Neil,  Great job!  Quick and right to the point.  Appreciate your help with this.

Neil FlemingConsultant and developerCommented:
Occurs to me that I reset the cell to white. You may want to put it back as an zero-colour cell, in which case you'd need:


Open in new window

Roy CoxGroup Finance ManagerCommented:
Why not just use a message box at the end of the code? Much simpler in my opinion.
Rob HensonFinance AnalystCommented:
Maybe the formatting could be Conditional based on the text entry. The default formatting won't then need resetting.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.