ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Flashing cells (https://www.excelbanter.com/excel-programming/428077-flashing-cells.html)

Max

Flashing cells
 
Will you please tell me what's wrong with this code?

Option Explicit
Dim nextSecond

Sub startFlashing()
flashCell
End Sub

Sub stopFlashing()
On Error Resume Next
Application.OnTime nextSecond, "flashCell", , False
End Sub

Sub flashCell()
nextSecond = Now + TimeValue("00:00:01")
Application.OnTime nextSecond, "flashCell"

With Sheets("Serie A")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"


ElseIf .Range("AN6").Interior.ColorIndex = 41 Then
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"

End If

If .Range("AW6").Interior.ColorIndex = 3 Then
.Range("AW6").Interior.ColorIndex = 41



ElseIf .Range("AW6").Interior.ColorIndex = 41 Then
.Range("AW6").Interior.ColorIndex = 3


With Sheets("Serie B")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"


ElseIf .Range("AN6").Interior.ColorIndex = 41 Then
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"

End If

If .Range("AW6").Interior.ColorIndex = 3 Then
.Range("AW6").Interior.ColorIndex = 41



ElseIf .Range("AW6").Interior.ColorIndex = 41 Then
.Range("AW6").Interior.ColorIndex = 3
End If
End With
End Sub


Harald Staff[_2_]

Flashing cells
 
It tries to make worksheet cells flash.

Seriously, why do you think something is wrong with it? Do you get error
messages or unexpected behavior? If so what?

Best wishes Harald


"MAX" wrote in message
...
Will you please tell me what's wrong with this code?

Option Explicit
Dim nextSecond

Sub startFlashing()
flashCell
End Sub

Sub stopFlashing()
On Error Resume Next
Application.OnTime nextSecond, "flashCell", , False
End Sub

Sub flashCell()
nextSecond = Now + TimeValue("00:00:01")
Application.OnTime nextSecond, "flashCell"

With Sheets("Serie A")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"


ElseIf .Range("AN6").Interior.ColorIndex = 41 Then
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"

End If

If .Range("AW6").Interior.ColorIndex = 3 Then
.Range("AW6").Interior.ColorIndex = 41



ElseIf .Range("AW6").Interior.ColorIndex = 41 Then
.Range("AW6").Interior.ColorIndex = 3


With Sheets("Serie B")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"


ElseIf .Range("AN6").Interior.ColorIndex = 41 Then
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"

End If

If .Range("AW6").Interior.ColorIndex = 3 Then
.Range("AW6").Interior.ColorIndex = 41



ElseIf .Range("AW6").Interior.ColorIndex = 41 Then
.Range("AW6").Interior.ColorIndex = 3
End If
End With
End Sub



Max

Flashing cells
 
This code is giving me Block If without End If

"Harald Staff" wrote:

It tries to make worksheet cells flash.

Seriously, why do you think something is wrong with it? Do you get error
messages or unexpected behavior? If so what?

Best wishes Harald


"MAX" wrote in message
...
Will you please tell me what's wrong with this code?

Option Explicit
Dim nextSecond

Sub startFlashing()
flashCell
End Sub

Sub stopFlashing()
On Error Resume Next
Application.OnTime nextSecond, "flashCell", , False
End Sub

Sub flashCell()
nextSecond = Now + TimeValue("00:00:01")
Application.OnTime nextSecond, "flashCell"

With Sheets("Serie A")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"


ElseIf .Range("AN6").Interior.ColorIndex = 41 Then
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"

End If

If .Range("AW6").Interior.ColorIndex = 3 Then
.Range("AW6").Interior.ColorIndex = 41



ElseIf .Range("AW6").Interior.ColorIndex = 41 Then
.Range("AW6").Interior.ColorIndex = 3


With Sheets("Serie B")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"


ElseIf .Range("AN6").Interior.ColorIndex = 41 Then
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"

End If

If .Range("AW6").Interior.ColorIndex = 3 Then
.Range("AW6").Interior.ColorIndex = 41



ElseIf .Range("AW6").Interior.ColorIndex = 41 Then
.Range("AW6").Interior.ColorIndex = 3
End If
End With
End Sub




Rick Rothstein

Flashing cells
 
You have two With statements but only one End With statement.

--
Rick (MVP - Excel)


"MAX" wrote in message
...
This code is giving me Block If without End If

"Harald Staff" wrote:

It tries to make worksheet cells flash.

Seriously, why do you think something is wrong with it? Do you get error
messages or unexpected behavior? If so what?

Best wishes Harald


"MAX" wrote in message
...
Will you please tell me what's wrong with this code?

Option Explicit
Dim nextSecond

Sub startFlashing()
flashCell
End Sub

Sub stopFlashing()
On Error Resume Next
Application.OnTime nextSecond, "flashCell", , False
End Sub

Sub flashCell()
nextSecond = Now + TimeValue("00:00:01")
Application.OnTime nextSecond, "flashCell"

With Sheets("Serie A")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"


ElseIf .Range("AN6").Interior.ColorIndex = 41 Then
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"

End If

If .Range("AW6").Interior.ColorIndex = 3 Then
.Range("AW6").Interior.ColorIndex = 41



ElseIf .Range("AW6").Interior.ColorIndex = 41 Then
.Range("AW6").Interior.ColorIndex = 3


With Sheets("Serie B")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"


ElseIf .Range("AN6").Interior.ColorIndex = 41 Then
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"

End If

If .Range("AW6").Interior.ColorIndex = 3 Then
.Range("AW6").Interior.ColorIndex = 41



ElseIf .Range("AW6").Interior.ColorIndex = 41 Then
.Range("AW6").Interior.ColorIndex = 3
End If
End With
End Sub





Howard31[_3_]

Flashing cells
 
There is also an End If missing

"Rick Rothstein" wrote in message
...
You have two With statements but only one End With statement.

--
Rick (MVP - Excel)


"MAX" wrote in message
...
This code is giving me Block If without End If

"Harald Staff" wrote:

It tries to make worksheet cells flash.

Seriously, why do you think something is wrong with it? Do you get error
messages or unexpected behavior? If so what?

Best wishes Harald


"MAX" wrote in message
...
Will you please tell me what's wrong with this code?

Option Explicit
Dim nextSecond

Sub startFlashing()
flashCell
End Sub

Sub stopFlashing()
On Error Resume Next
Application.OnTime nextSecond, "flashCell", , False
End Sub

Sub flashCell()
nextSecond = Now + TimeValue("00:00:01")
Application.OnTime nextSecond, "flashCell"

With Sheets("Serie A")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"


ElseIf .Range("AN6").Interior.ColorIndex = 41 Then
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"

End If

If .Range("AW6").Interior.ColorIndex = 3 Then
.Range("AW6").Interior.ColorIndex = 41



ElseIf .Range("AW6").Interior.ColorIndex = 41 Then
.Range("AW6").Interior.ColorIndex = 3


With Sheets("Serie B")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"


ElseIf .Range("AN6").Interior.ColorIndex = 41 Then
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"

End If

If .Range("AW6").Interior.ColorIndex = 3 Then
.Range("AW6").Interior.ColorIndex = 41



ElseIf .Range("AW6").Interior.ColorIndex = 41 Then
.Range("AW6").Interior.ColorIndex = 3
End If
End With
End Sub






Howard31[_3_]

Flashing cells
 
Because your'e using ElseIf, both statements (interiorColor=3 & 41) are
evaluated within each second that's why it's not noticable the changes, use
instead Else as follows:

With Sheets("Serie A")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"
Else
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"
End If
End With

"MAX" wrote in message
...
Will you please tell me what's wrong with this code?

Option Explicit
Dim nextSecond

Sub startFlashing()
flashCell
End Sub

Sub stopFlashing()
On Error Resume Next
Application.OnTime nextSecond, "flashCell", , False
End Sub

Sub flashCell()
nextSecond = Now + TimeValue("00:00:01")
Application.OnTime nextSecond, "flashCell"

With Sheets("Serie A")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"


ElseIf .Range("AN6").Interior.ColorIndex = 41 Then
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"

End If

If .Range("AW6").Interior.ColorIndex = 3 Then
.Range("AW6").Interior.ColorIndex = 41



ElseIf .Range("AW6").Interior.ColorIndex = 41 Then
.Range("AW6").Interior.ColorIndex = 3


With Sheets("Serie B")
If .Range("AN6").Interior.ColorIndex = 3 Then
.Range("AN6").Interior.ColorIndex = 41
.Range("AN6").Value = "Champ"


ElseIf .Range("AN6").Interior.ColorIndex = 41 Then
.Range("AN6").Interior.ColorIndex = 3
.Range("AN6").Value = "Champ"

End If

If .Range("AW6").Interior.ColorIndex = 3 Then
.Range("AW6").Interior.ColorIndex = 41



ElseIf .Range("AW6").Interior.ColorIndex = 41 Then
.Range("AW6").Interior.ColorIndex = 3
End If
End With
End Sub




All times are GMT +1. The time now is 09:22 PM.

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