How to Make a Shape Blink in Excel Using VBA | WPS Spreadsheet
Question details
The user wants to make a shape blink in a spreadsheet to draw attention to specific cells, values, or visual indicators.

- Product
- Excel / WPS Spreadsheet
- Device & OS
- not provided
- Scenario
- Creating dynamic visual alerts or indicators in a workbook by making a designated shape continuously change colors.
- Observed behavior
- Excel lacks a built-in blinking shape feature, requiring a VBA workaround utilizing scheduled events to alternate the shape's fill color.
Ensure you have the Developer tab enabled in your spreadsheet program and that your workbook is saved as a Macro-Enabled Workbook (.xlsm) so your VBA code is retained after saving.
Use the VBA Application.OnTime Method
Write a VBA script that changes the shape's color at scheduled intervals using the Application.OnTime method to simulate a blinking effect.
Since there is no native flashing feature, this method relies on two separate macros: one to start the flashing effect by changing the scheme color at one-second intervals, and another to stop the timer and revert the shape to its original color.
Be sure to replace 'Rounded Rectangle 4' in the code with the actual name of the shape you are using in your worksheet.
Navigate to the Developer tab on the ribbon and click 'Visual Basic', or simply press Alt + F11 on your keyboard to open the Visual Basic for Applications editor.
In the VBA editor, right-click on your workbook name in the Project Explorer panel, select 'Insert', and then click 'Module' to create a blank canvas for your code.
Copy and paste the following code into the module window. Make sure variables are declared at the very top: Dim NextTime As Date Dim xColor As Long Sub Flash() NextTime = Now + TimeValue("00:00:01") With ActiveSheet.Shapes("Rounded Rectangle 4").Fill.ForeColor If xColor = 0 Then xColor = .SchemeColor .SchemeColor = Int(Rnd() * 55 + 1) End With Application.OnTime NextTime, "Flash" End Sub Sub StopIt() Application.OnTime NextTime, "Flash", Schedule:=False ActiveSheet.Shapes("Rounded Rectangle 4").Fill.ForeColor.SchemeColor = xColor xColor = 0 End Sub
Return to your worksheet, press Alt + F8 to open the Macro dialog, select 'Flash' from the list, and click 'Run' to start the blinking effect. To stop it, run the 'StopIt' macro.

Create and Run VBA Macros Seamlessly in WPS Spreadsheet
WPS Office provides robust support for VBA and macros, allowing you to automate tasks and create dynamic elements like blinking shapes just as you would in Microsoft Excel.
- 1. Download WPS Office: Download and install the free version of WPS Office from the official website.
- 2. Open the Developer Tab: Launch WPS Spreadsheet, open your file, and navigate to the 'Developer' tab on the main ribbon.
- 3. Access the VBA Editor: Click 'Visual Basic' to launch the integrated VBA editor and insert your custom shape-blinking macros effortlessly.

Frequently Asked Questions
How do I find the exact name of my shape to use in the VBA code?
Click on the shape in your worksheet to select it. Look at the Name Box located to the left of the formula bar. The text displayed there (e.g., 'Rounded Rectangle 4') is the exact name you need to put in your VBA script.
Why does my workbook reopen itself after I close it?
This happens if you close the workbook while the Application.OnTime schedule is still running in the background. To fix this, always execute the macro that cancels the schedule (the 'StopIt' sub) before closing the file.
Can I make the shape blink faster than one second?
Using the standard Application.OnTime method, the minimum time interval is one second via TimeValue("00:00:01"). Making it blink in milliseconds requires advanced Windows API calls (like Sleep or SetTimer), which is much more complex and can make the application unresponsive.




