prepalot
01-26-2008, 11:38 AM
Hoping someone can please help me with the macro which I?ve posted below (not mine, got it from this site). I?m trying to tailor it to my needs. BTW, I am new to this site ? and new to VBA altogether.
Example of what I?m trying to do: I want to apply the blinking cell property to (let?s say) A1, but only when K11 meets a certain condition. Additionally, in the same worksheet, I would like A2 to blink, but only when K12 meets a certain condition. In other words, I would like these specifically married cells (A1 and K11) or (A2 and K12) to work together in activating this code ? simultaneously ? in the same worksheet.
Can this even be done? I?ve tinkered and tinkered with no success.
If you have a better code to accomplish this ? please feel free to post it.
Thank you in advance - your brilliant expertise would be respectfully appreciated!
Option Explicit
Public RunWhen As Double
Sub StartBlink()
If Range("A1").Interior.ColorIndex = 3 Then
Range("A1").Interior.ColorIndex = 6
Else
Range("A1").Interior.ColorIndex = 3
End If
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "StartBlink", , True
End Sub
Sub StopBlink()
Range("A1").Interior.ColorIndex = xlAutomatic
Application.OnTime RunWhen, "StartBlink", , False
End Sub
'Then Place this code into the code module of the specific worksheet you want to work with
Option Explicit
Public CellCheck As Boolean
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Change the IF statement and cell range to what you need
If Range("A1") = "1" And CellCheck = False Then
Call StartBlink
CellCheck = True
ElseIf Range("A1") <> "1" And CellCheck = True Then
Call StopBlink
CellCheck = False
End If
End Sub
Example of what I?m trying to do: I want to apply the blinking cell property to (let?s say) A1, but only when K11 meets a certain condition. Additionally, in the same worksheet, I would like A2 to blink, but only when K12 meets a certain condition. In other words, I would like these specifically married cells (A1 and K11) or (A2 and K12) to work together in activating this code ? simultaneously ? in the same worksheet.
Can this even be done? I?ve tinkered and tinkered with no success.
If you have a better code to accomplish this ? please feel free to post it.
Thank you in advance - your brilliant expertise would be respectfully appreciated!
Option Explicit
Public RunWhen As Double
Sub StartBlink()
If Range("A1").Interior.ColorIndex = 3 Then
Range("A1").Interior.ColorIndex = 6
Else
Range("A1").Interior.ColorIndex = 3
End If
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "StartBlink", , True
End Sub
Sub StopBlink()
Range("A1").Interior.ColorIndex = xlAutomatic
Application.OnTime RunWhen, "StartBlink", , False
End Sub
'Then Place this code into the code module of the specific worksheet you want to work with
Option Explicit
Public CellCheck As Boolean
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Change the IF statement and cell range to what you need
If Range("A1") = "1" And CellCheck = False Then
Call StartBlink
CellCheck = True
ElseIf Range("A1") <> "1" And CellCheck = True Then
Call StopBlink
CellCheck = False
End If
End Sub