M
MAX
I want cells B1 and F1 flashing, and I am using this code (below). When I run
the macro, it is giving me a compile error ( Block If without End If).
Any help please?
This is the 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"
If Range("B1").Interior.ColorIndex = 7 Then
Sheet1.Range("B1").Interior.ColorIndex = 41
Sheet1.Range("B1").Value = "Light Blue"
ElseIf Range("B1").Interior.ColorIndex = 41 Then
Sheet1.Range("B1").Interior.ColorIndex = 7
Sheet1.Range("B1").Value = "Pink"
If Range("F1").Interior.ColorIndex = 7 Then
Sheet1.Range("F1").Interior.ColorIndex = 41
Sheet1.Range("F1").Value = "Light Blue"
ElseIf Range("F1").Interior.ColorIndex = 41 Then
Sheet1.Range("F1").Interior.ColorIndex = 7
Sheet1.Range("F1").Value = "Pink"
End If
End Sub
Thanks a lot.
the macro, it is giving me a compile error ( Block If without End If).
Any help please?
This is the 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"
If Range("B1").Interior.ColorIndex = 7 Then
Sheet1.Range("B1").Interior.ColorIndex = 41
Sheet1.Range("B1").Value = "Light Blue"
ElseIf Range("B1").Interior.ColorIndex = 41 Then
Sheet1.Range("B1").Interior.ColorIndex = 7
Sheet1.Range("B1").Value = "Pink"
If Range("F1").Interior.ColorIndex = 7 Then
Sheet1.Range("F1").Interior.ColorIndex = 41
Sheet1.Range("F1").Value = "Light Blue"
ElseIf Range("F1").Interior.ColorIndex = 41 Then
Sheet1.Range("F1").Interior.ColorIndex = 7
Sheet1.Range("F1").Value = "Pink"
End If
End Sub
Thanks a lot.