Error with macro - help needed

prinztegame

New Member
Joined
Dec 12, 2010
Messages
22
Good morning to all of you people, I need some help to solve a problem. I have the following macro that allows a cell to flash alternatively red and yellow when a condition is met:

Sub Flash()
If Range("K13").Value = "TRUE" Then
Dim PauseTime, Start, Finish
For x = 1 To 4
PauseTime = 0.5
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Range("H37").Cells.Interior.ColorIndex = 3
Loop
Finish = Timer
PauseTime = 0.5
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Range("H37").Cells.Interior.ColorIndex = 6
Loop
Finish = Timer
Next x
Range("H37").Cells.Interior.ColorIndex = xlNone
End
End If
End Sub

Does anyone know why I get an "Error 1004 - impossibile to execute - Color Index" whenever the sheet is protected with a password, and I don't when the sheet is free?
Since I need to protect the sheet does anyone knows how to solve the problem?
Thank you very much in advance to all of you!!!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Does anyone know why I get an "Error 1004 - impossibile to execute - Color Index" whenever the sheet is protected with a password, and I don't when the sheet is free?
Since I need to protect the sheet does anyone knows how to solve the problem?
Why not just unprotect the sheet at the start of the code and reprotect it at the end. Example, underneath the line
If Range("K13").Value = "TRUE" Then
enter
ActiveSheet.Unprotect ("YourPassword")

and immediately above the line
End If
enter
ActiveSheet.Protect ("YourPassword")

Of course, substitute "YourPassword" with whatever the password really is.
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,345
Members
452,907
Latest member
Roland Deschain

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