Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 79
  • 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
 
NorieVBA ExpertCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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