Solved

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

Posted on 2014-12-21
4
70 Views
Last Modified: 2014-12-24
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
Comment
Question by:dgd1212
  • 2
4 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 40511568
How/why are you changing the cell colour?
0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40511570
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
 
LVL 11

Accepted Solution

by:
Wilder1626 earned 500 total points
ID: 40511591
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
 

Author Closing Comment

by:dgd1212
ID: 40516451
Thanks!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question