Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding code | Excel Programming | |||
Creating excel file, adding code to it from code, VBE window stays | Excel Programming | |||
adding code lines with vba code | Excel Programming | |||
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. | Excel Programming | |||
adding to a VBA COde | Excel Programming |