ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Blinking cells (https://www.excelbanter.com/excel-programming/427610-blinking-cells.html)

Max

Blinking cells
 
I have a workbook with 3 sheets and sheet 1 has cell A1 as a blinking cell (
code below). Now I want also sheet 2 and sheet 3 with a blinking cell ( cell
A2 in both sheets).
This is the code:

In Workbook
Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

In Module:
Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("Sheet1").Range("A1").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("Sheet1").Range("A1").Font .ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

Any help please?
Thank you.

ryguy7272

Blinking cells
 
Change the code in the appropriate places:
Sub StartBlink()
With ThisWorkbook.Worksheets("Sheet2").Range("A2").Font
'etc...

Also,
Sub StopBlink()
ThisWorkbook.Worksheets("Sheet2").Range("A2").Font .ColorIndex = _
'etc...

HTH,
Ryan---
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"MAX" wrote:

I have a workbook with 3 sheets and sheet 1 has cell A1 as a blinking cell (
code below). Now I want also sheet 2 and sheet 3 with a blinking cell ( cell
A2 in both sheets).
This is the code:

In Workbook
Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

In Module:
Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("Sheet1").Range("A1").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("Sheet1").Range("A1").Font .ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

Any help please?
Thank you.


Max

Blinking cells
 
I have to open a new modoule for each sheet or add them to the one I have?

"ryguy7272" wrote:

Change the code in the appropriate places:
Sub StartBlink()
With ThisWorkbook.Worksheets("Sheet2").Range("A2").Font
'etc...

Also,
Sub StopBlink()
ThisWorkbook.Worksheets("Sheet2").Range("A2").Font .ColorIndex = _
'etc...

HTH,
Ryan---
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"MAX" wrote:

I have a workbook with 3 sheets and sheet 1 has cell A1 as a blinking cell (
code below). Now I want also sheet 2 and sheet 3 with a blinking cell ( cell
A2 in both sheets).
This is the code:

In Workbook
Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

In Module:
Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("Sheet1").Range("A1").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("Sheet1").Range("A1").Font .ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

Any help please?
Thank you.


ryguy7272

Blinking cells
 
Try this:

Sub StartBlink2()
Sub StartBlink3()
€˜etc€¦

Change the sheet names and the cell references. Place all in the same
module. Try it and see if it works the way you need it to work. Trying and
doing; best ways to learn. If it doesn't work, try something slightly
different, and if that doesn't work, you can certainly post back for more
help.

HTH,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"MAX" wrote:

I have to open a new modoule for each sheet or add them to the one I have?

"ryguy7272" wrote:

Change the code in the appropriate places:
Sub StartBlink()
With ThisWorkbook.Worksheets("Sheet2").Range("A2").Font
'etc...

Also,
Sub StopBlink()
ThisWorkbook.Worksheets("Sheet2").Range("A2").Font .ColorIndex = _
'etc...

HTH,
Ryan---
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"MAX" wrote:

I have a workbook with 3 sheets and sheet 1 has cell A1 as a blinking cell (
code below). Now I want also sheet 2 and sheet 3 with a blinking cell ( cell
A2 in both sheets).
This is the code:

In Workbook
Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

In Module:
Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("Sheet1").Range("A1").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("Sheet1").Range("A1").Font .ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

Any help please?
Thank you.


Max

Blinking cells
 
Now I have this code (below) and only the cell in sheet 1 is blinking when I
open the workbook. In sheet 2 and sheet 3, I have to go to macro and run from
there so that the cells start blinking. I need that when I open the workbook
I found the cells already blinking in all sheets.

This is the code.

In Workbook:

Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

In Module:

Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("Sheet1").Range("A1").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("Sheet1").Range("A1").Font .ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub


Sub StartBlink2()
With ThisWorkbook.Worksheets("Sheet2").Range("A2").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink2", ,
True
End Sub

Sub StopBlink2()
ThisWorkbook.Worksheets("Sheet2").Range("A2").Font .ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink2", ,
False
End Sub
Sub StartBlink3()
With ThisWorkbook.Worksheets("Sheet3").Range("A2").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink3", ,
True
End Sub

Sub StopBlink3()
ThisWorkbook.Worksheets("Sheet3").Range("A2").Font .ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink3", ,
False
End Sub

Thanks for your help Ryan.



"MAX" wrote:

I have a workbook with 3 sheets and sheet 1 has cell A1 as a blinking cell (
code below). Now I want also sheet 2 and sheet 3 with a blinking cell ( cell
A2 in both sheets).
This is the code:

In Workbook
Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

In Module:
Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("Sheet1").Range("A1").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("Sheet1").Range("A1").Font .ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

Any help please?
Thank you.


ryguy7272

Blinking cells
 
I really misunderstood what you were looking for before. I think this is
what you want:
In ThisWorkbook
Private Sub Workbook_Open()
StartBlink
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

In the Module:
Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("Sheet1").Range("A1").Font

If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With

With ThisWorkbook.Worksheets("Sheet2").Range("A2").Font

If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With

With ThisWorkbook.Worksheets("Sheet3").Range("A2").Font

If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With

RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("Sheet1").Range("A1").Font .ColorIndex = _
xlColorIndexAutomatic

ThisWorkbook.Worksheets("Sheet2").Range("A2").Font .ColorIndex = _
xlColorIndexAutomatic

ThisWorkbook.Worksheets("Sheet3").Range("A2").Font .ColorIndex = _
xlColorIndexAutomatic

Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"MAX" wrote:

Now I have this code (below) and only the cell in sheet 1 is blinking when I
open the workbook. In sheet 2 and sheet 3, I have to go to macro and run from
there so that the cells start blinking. I need that when I open the workbook
I found the cells already blinking in all sheets.

This is the code.

In Workbook:

Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

In Module:

Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("Sheet1").Range("A1").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("Sheet1").Range("A1").Font .ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub


Sub StartBlink2()
With ThisWorkbook.Worksheets("Sheet2").Range("A2").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink2", ,
True
End Sub

Sub StopBlink2()
ThisWorkbook.Worksheets("Sheet2").Range("A2").Font .ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink2", ,
False
End Sub
Sub StartBlink3()
With ThisWorkbook.Worksheets("Sheet3").Range("A2").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink3", ,
True
End Sub

Sub StopBlink3()
ThisWorkbook.Worksheets("Sheet3").Range("A2").Font .ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink3", ,
False
End Sub

Thanks for your help Ryan.



"MAX" wrote:

I have a workbook with 3 sheets and sheet 1 has cell A1 as a blinking cell (
code below). Now I want also sheet 2 and sheet 3 with a blinking cell ( cell
A2 in both sheets).
This is the code:

In Workbook
Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

In Module:
Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("Sheet1").Range("A1").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("Sheet1").Range("A1").Font .ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

Any help please?
Thank you.


dk[_2_]

Blinking cells
 
On Apr 28, 3:34*am, MAX wrote:
I have a workbook with 3 sheets and sheet 1 has cell A1 as a *blinking cell (
code below). Now I want also sheet 2 and sheet 3 with a blinking cell ( cell
A2 in both sheets).
This is the code:

In Workbook
Private Sub Workbook_Open()
* * StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
* * StopBlink
End Sub

In Module:
Public RunWhen As Double

Sub StartBlink()
* * With ThisWorkbook.Worksheets("Sheet1").Range("A1").Font
* * * * If .ColorIndex = 3 Then ' Red Text
* * * * * * .ColorIndex = 2 ' White Text
* * * * Else
* * * * * * .ColorIndex = 3 ' Red Text
* * * * End If
* * End With
* * RunWhen = Now + TimeSerial(0, 0, 1)
* * Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
True
End Sub

Sub StopBlink()
* * ThisWorkbook.Worksheets("Sheet1").Range("A1").Font .ColorIndex = _
* * * * xlColorIndexAutomatic
* * Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

Any help please?
Thank you.


JUST REPLACE THIS:

ThisWorkbook.Worksheets("Sheet1")

with

ActiveSheet



All times are GMT +1. The time now is 05:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com