Excel macro error

Closed
bigmac99 Posts 1 Registration date Friday 30 August 2013 Status Member Last seen 30 August 2013 - 30 Aug 2013 à 11:54
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 3 Sep 2013 à 10:55
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 31 August 2010 Status Contributor Last seen 20 June 2016 26
30 Aug 2013 à 13:23
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'.
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 555
2 Sep 2013 à 11:12
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
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
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 555
3 Sep 2013 à 10:55
Thanks Ray, it's working now.