Excel macro error

Closed
bigmac99 Posts 1 Registration date Friday August 30, 2013 Status Member Last seen August 30, 2013 - Aug 30, 2013 at 11:54 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen January 16, 2023 - Sep 3, 2013 at 10:55 AM
I recently tried this macro to make a cell in excel blink but it gives me an error. Our of range error 9

This is the macro

Dim NextTime As Date
Sub StartFlash()
NextTime = Now + TimeValue("00:00:01")
With ActiveWorkbook.Styles("Flashing").Font
If .ColorIndex = xlAutomatic Then .ColorIndex = 3
.ColorIndex = 5 - .ColorIndex
End With
Application.OnTime NextTime, "StartFlash"
End Sub


Any suggestions?

This is the line with the error.
With ActiveWorkbook.Styles("Flashing").Font

Dale
Related:

4 responses

RayH Posts 122 Registration date Tuesday August 31, 2010 Status Contributor Last seen June 20, 2016 26
Aug 30, 2013 at 01:23 PM
https://ccm.net/faq/29065-excel-a-macro-to-make-cells-blinks

You need to create the style name first. See the link above. Although in that link they have defined the Style to be called 'Blinking' and yet use the same code as you are have but reference 'Flashing'.
0
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen January 16, 2023 549
Sep 2, 2013 at 11:12 AM
Hello,

A blinking cell sounds interesting, so I gave it a try.

I changed the style of A1 (and put some data in it) from Arial to Flashing (Same as reference in the code), run the code and got the same error as Dale.

I tried to format the entire sheet as Flashing, with no success.

I'm using Excel 2003, maybe it only works with the latest versions? But that is pure speculation.

Did someone get this to work?

Best regards,
Trowa
0
Yes. It works just fine without any code changes.
The error message appears because the 'Flashing' style is not defined.

http://office.microsoft.com/en-us/excel-help/using-styles-in-excel-HA001110199.aspx
0
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen January 16, 2023 549
Sep 3, 2013 at 10:55 AM
Thanks Ray, it's working now.
0