ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run macro when cell color changes (https://www.excelbanter.com/excel-programming/386325-run-macro-when-cell-color-changes.html)

Marjo

Run macro when cell color changes
 
I have a worksheet with dates in row 1 spreading over several columns.
This range of dates is named TuitionDaysA.
Some of the dates are color coded (yellow).
I have created a macro that counts the cells in row 1 that are colored
yellow and have the result put in cell C13:
Sub ColorCountProgA()
yellow = 0
For Each Cell In Sheet1.Range("TuitionDaysA")
If Cell.Interior.ColorIndex = 6 Then
yellow = yellow + 1
Else
End If
Next
If yellow 0 Then
Sheet1.Cells(13, 3).FormulaR1C1 = yellow
Else
End If
End Sub

How do I change this code so that when the color of a cell in row 1 changes,
C13 is automatically updated.


joel

Run macro when cell color changes
 
Sorry, color changes don't cause worksheet to update. therefore, you can't
do what you want to do.

"Marjo" wrote:

I have a worksheet with dates in row 1 spreading over several columns.
This range of dates is named TuitionDaysA.
Some of the dates are color coded (yellow).
I have created a macro that counts the cells in row 1 that are colored
yellow and have the result put in cell C13:
Sub ColorCountProgA()
yellow = 0
For Each Cell In Sheet1.Range("TuitionDaysA")
If Cell.Interior.ColorIndex = 6 Then
yellow = yellow + 1
Else
End If
Next
If yellow 0 Then
Sheet1.Cells(13, 3).FormulaR1C1 = yellow
Else
End If
End Sub

How do I change this code so that when the color of a cell in row 1 changes,
C13 is automatically updated.



All times are GMT +1. The time now is 02:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com