Script Out of range error

Krishnab4u

New Member
Joined
Jul 16, 2018
Messages
34
Dear All,
I want a particular cell to blink until the value set to today's date.
following is the code used.

Code:
Option Explicit
Public RunWhen As Double
 
Sub StartBlink()
[U][I][B]With Worksheets("Summary")[/B][/I][/U]
.EnableOutlining = True
.Protect Password:="isuzu", _
Contents:=True, UserInterfaceOnly:=True
End With
   If Worksheets("Summary").Range("X2:AA2").Interior.ColorIndex = 3 Then
      Worksheets("Summary").Range("X2:AA2").Interior.ColorIndex = 4
    Else
        Worksheets("Summary").Range("X2:AA2").Interior.ColorIndex = 3
    End If
    RunWhen = Now + TimeSerial(0, 0, 2)
    Application.OnTime RunWhen, "StartBlink", , True
End Sub
 
Sub StopBlink()
On Error Resume Next
 Worksheets("Summary").Range("X2:AA2").Interior.ColorIndex = 30
 Worksheets("Summary").Range("X2:AA2").Interior.Pattern = xlPatternLinearGradient
 Application.OnTime RunWhen, "StartBlink", , False
End Sub

while the cell is blinking if i try to "Alt Tab" to see another workbook i get the error as "Run time error 9; Script out of range" and highlights line With Worksheets("Summary") in the above code (font bold and italised).

Please help.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
It means there is no worksheet named Summary in the active workbook.
 
Upvote 0
Yes, there is no worksheet in the active workbook (which i just see by Alt Tab). However, the workbook which has the code running is very much having sheet called summary.
 
Upvote 0
Code:
With ThisWorkbook.Worksheets("Summary")
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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