#1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default Adding code

Hello
I have this code (below) and I wish to add another Interior.ColorIndex 5 and
another Value "Media". Is this possible?

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 = 6
Range("D7").Value = "SPORT"

ElseIf Range("D7").Interior.ColorIndex = 6 Then
Range("D7").Interior.ColorIndex = 4
Range("D7").Value = "EDUCATION"

End If
End Sub

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default Adding code

Yes, Just copy the 3-lines from the ElseIf group and paste it right below
that group and then modify it as needed to test for and set the color index
of D7 and to set the value to = "Media".


"MAX" wrote:

Hello
I have this code (below) and I wish to add another Interior.ColorIndex 5 and
another Value "Media". Is this possible?

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 = 6
Range("D7").Value = "SPORT"

ElseIf Range("D7").Interior.ColorIndex = 6 Then
Range("D7").Interior.ColorIndex = 4
Range("D7").Value = "EDUCATION"

End If
End Sub

Thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Adding code

You will need ot add in the missing info below.

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 = 6
Range("D7").Value = "SPORT"

ElseIf Range("D7").Interior.ColorIndex = 6 Then
Range("D7").Interior.ColorIndex = 4
Range("D7").Value = "EDUCATION"

ElseIf Range("D7").Interior.ColorIndex = 5 Then
Range("D7").Interiror.ColorIndex = ? '<<<<You did not
specify
Range("D7").Value = "Media"

End If
End Sub







"MAX" wrote in message
...
Hello
I have this code (below) and I wish to add another Interior.ColorIndex 5
and
another Value "Media". Is this possible?

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 = 6
Range("D7").Value = "SPORT"

ElseIf Range("D7").Interior.ColorIndex = 6 Then
Range("D7").Interior.ColorIndex = 4
Range("D7").Value = "EDUCATION"

End If
End Sub

Thanks in advance



  #4   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default Adding code

I did that but it did not work. Will you please do the code for me since I am
a very beginner.

Thanks a lot

"JLatham" wrote:

Yes, Just copy the 3-lines from the ElseIf group and paste it right below
that group and then modify it as needed to test for and set the color index
of D7 and to set the value to = "Media".


"MAX" wrote:

Hello
I have this code (below) and I wish to add another Interior.ColorIndex 5 and
another Value "Media". Is this possible?

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 = 6
Range("D7").Value = "SPORT"

ElseIf Range("D7").Interior.ColorIndex = 6 Then
Range("D7").Interior.ColorIndex = 4
Range("D7").Value = "EDUCATION"

End If
End Sub

Thanks in advance

  #5   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default Adding code

I want Interior.ColorIndex 5 and Interior.ColorIndex 3

"MAX" wrote:

Hello
I have this code (below) and I wish to add another Interior.ColorIndex 5 and
another Value "Media". Is this possible?

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 = 6
Range("D7").Value = "SPORT"

ElseIf Range("D7").Interior.ColorIndex = 6 Then
Range("D7").Interior.ColorIndex = 4
Range("D7").Value = "EDUCATION"

End If
End Sub

Thanks in advance



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default Adding code

Try this:

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


"MAX" wrote:

I did that but it did not work. Will you please do the code for me since I am
a very beginner.

Thanks a lot

"JLatham" wrote:

Yes, Just copy the 3-lines from the ElseIf group and paste it right below
that group and then modify it as needed to test for and set the color index
of D7 and to set the value to = "Media".


"MAX" wrote:

Hello
I have this code (below) and I wish to add another Interior.ColorIndex 5 and
another Value "Media". Is this possible?

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 = 6
Range("D7").Value = "SPORT"

ElseIf Range("D7").Interior.ColorIndex = 6 Then
Range("D7").Interior.ColorIndex = 4
Range("D7").Value = "EDUCATION"

End If
End Sub

Thanks in advance

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating excel file, adding code to it from code, VBE window stays BlueWolverine Excel Programming 0 November 5th 09 07:55 PM
adding code lines with vba code thread Excel Programming 4 February 6th 08 01:31 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
adding to a VBA COde diacci1st Excel Programming 0 November 23rd 06 11:21 AM
Adding space to VBA code John Excel Programming 1 June 28th 04 08:56 PM


All times are GMT +1. The time now is 04:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"