• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 77
  • Last Modified:

How to call a macro when a cell goes from black text to red text

I have macro's in place to manually run if certain cells have red text. Is there a way to call a macro w/o manual intervention when a cells text changes from black to red?
Thanks
0
dgd1212
Asked:
dgd1212
  • 2
1 Solution
 
NorieData ProcessorCommented:
How/why are you changing the cell colour?
0
 
Wilder1626Commented:
hI

You can do something like below:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim lRow As Long
Dim iCntr As Long
lRow = 20
For iCntr = lRow To 1 Step -1
If Cells(iCntr, 1).Font.ColorIndex = 3 Then
CommandButton1.Value = True
End If
Next
End Sub

Open in new window

0
 
Wilder1626Commented:
Another way could also be:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim t As Range
If Not Intersect(Target, Range("A1:A" & Rows.Count)) Is Nothing Then
         Set Rng = Intersect(Target, Range("A1:A" & Rows.Count))
         For Each t In Rng
             If t.Font.ColorIndex = 3 Then
              CommandButton1.Value = True
            End If
         Next t
End If
End Sub

Open in new window

0
 
dgd1212Author Commented:
Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now