VBA Code to execute specific worksheet

abelee

New Member
Joined
Aug 26, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi, I am a newbie in VBA codings. I have tried to flashing a cell in sheet2 (i have 5 sheets in the workbook/file) by pasting a ready made vba code into Thisworkbook as follows:

'Put in “ThisWorkbook”window
Private Sub Workbook_Open()
StarBlink
End Sub

However, all the cells (sheet2 and "c5" assigned in module1) in all sheets are flashing. Can some help and provide me a correct code to execute the flashing only on sheet2? Thanks.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Without knowing your code it's hard to tell.

Maybe "Worksheet_Activate" on "Sheet2"?
 
Upvote 0
Without knowing your code it's hard to tell.

Maybe "Worksheet_Activate" on "Sheet2"?
dear PeteWright, below is the full code inserted in module for sheet2;

'Start blinking
Sub StarBlink()
Dim xCell As Range
Dim xTime As Variant
Set xCell = Range("c5")
With ThisWorkbook.Worksheets("SHEET2").Range("c5").Font
If xCell.Font.Color = vbRed Then
xCell.Font.Color = vbWhite
Else
xCell.Font.Color = vbRed
End If
End With
xTime = Now + TimeSerial(0, 0, 1)
Application.OnTime xTime, "" & ThisWorkbook.Name & "!StarBlink", , True
End Sub
'Stop blinking
Sub StopBlink()
xTime = Now + TimeSerial(0, 0, 1)
Application.OnTime EarliestTime:=xTime, Procedure:="" & ThisWorkbook.Name & "!StarBlink", Schedule:=False
End Sub

thanks in advance
 
Upvote 0

Forum statistics

Threads
1,215,096
Messages
6,123,074
Members
449,093
Latest member
ripvw

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