PC Review


Reply
 
 
MAX
Guest
Posts: n/a
 
      20th Apr 2010
Hello
I have this code (below) and I wish to add another Interior.ColorIndex and
another Value, what code I have to add and where I have to insert it?

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("D7").Interior.ColorIndex = 4 Then
Range("D7").Interior.ColorIndex = 5
Range("D7").Value = "SPORT"

ElseIf Range("D7").Interior.ColorIndex = 5 Then
Range("D7").Interior.ColorIndex = 3
Range("D7").Value = "EDUCATION"

ElseIf Range("D7").Interior.ColorIndex = 3 Then
Range("D7").Interior.ColorIndex = 4
Range("D7").Value = "Media"

Else
'to kick it all off
Range("D7").Interior.ColorIndex = 4
Range("D7").Value = "Media"

End If
End Sub

Thanks in advance.

 
Reply With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      21st Apr 2010
Hi Max,

I would use Select Case. That way it is easy to just add another case
statement.

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

Select Case Range("D7").Interior.ColorIndex
Case 4
Range("D7").Interior.ColorIndex = 5
Range("D7").Value = "SPORT"

Case 5
Range("D7").Interior.ColorIndex = 3
Range("D7").Value = "EDUCATION"

Case 3
Range("D7").Interior.ColorIndex = 4
Range("D7").Value = "Media"

Case Else
'to kick it all off
Range("D7").Interior.ColorIndex = 4
Range("D7").Value = "Media"

End Select

End Sub


--
Regards,

OssieMac


"MAX" wrote:

> Hello
> I have this code (below) and I wish to add another Interior.ColorIndex and
> another Value, what code I have to add and where I have to insert it?
>
> 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("D7").Interior.ColorIndex = 4 Then
> Range("D7").Interior.ColorIndex = 5
> Range("D7").Value = "SPORT"
>
> ElseIf Range("D7").Interior.ColorIndex = 5 Then
> Range("D7").Interior.ColorIndex = 3
> Range("D7").Value = "EDUCATION"
>
> ElseIf Range("D7").Interior.ColorIndex = 3 Then
> Range("D7").Interior.ColorIndex = 4
> Range("D7").Value = "Media"
>
> Else
> 'to kick it all off
> Range("D7").Interior.ColorIndex = 4
> Range("D7").Value = "Media"
>
> End If
> End Sub
>
> Thanks in advance.
>

 
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
Creating excel file, adding code to it from code, VBE window stays BlueWolverine Microsoft Excel Programming 0 5th Nov 2009 07:55 PM
code for adding media player using c# code ram achar Microsoft C# .NET 0 14th Feb 2007 08:58 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Microsoft Excel Programming 3 11th Dec 2006 05:14 AM
Adding code to existing Code Heather Microsoft Access VBA Modules 0 24th Aug 2004 07:26 PM
Adding Code Groups and PermissionSets through code Thomas Delrue Microsoft Dot NET Framework 2 30th Oct 2003 12:53 PM


Features
 

Advertising
 

Newsgroups
 


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