PC Review


Reply
Thread Tools Rate Thread

Cells flashing

 
 
MAX
Guest
Posts: n/a
 
      6th May 2009
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.
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      6th May 2009
You are missing and End If after your firs If....ElseIf... statements.


"MAX" <(E-Mail Removed)> wrote in message
news:05EFF7F6-4862-4C8F-B9F0-(E-Mail Removed)...
>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.



 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      6th May 2009
Please read the opening paragraph and BE SURE TO READ the last item in the
Summary at the bottom of the page...

http://www.cpearson.com/excel/BlinkingText.aspx

--
Rick (MVP - Excel)


"MAX" <(E-Mail Removed)> wrote in message
news:05EFF7F6-4862-4C8F-B9F0-(E-Mail Removed)...
>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.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Flashing Cells DT Microsoft Excel Discussion 9 20th Jan 2010 04:17 PM
Flashing cells sonicscooter Microsoft Excel Programming 0 9th May 2009 12:26 PM
Flashing cells Haggis Microsoft Excel Discussion 2 3rd Dec 2007 02:24 PM
Flashing cells John Microsoft Excel Worksheet Functions 2 25th Aug 2004 05:02 PM
Flashing cells =?Utf-8?B?RHVibGluIFRyYWluZXI=?= Microsoft Excel Crashes 1 6th Apr 2004 07:47 PM


Features
 

Advertising
 

Newsgroups
 


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