Update automatically when using VBA

Even

Board Regular
Joined
Jan 1, 2013
Messages
81
Office Version
  1. 365
Platform
  1. Windows
Hi,
this Excel model I am using is working pretty nicely, however, it is not updating like I want. Whenever I select a predefined text in a cell in column C, the cell is suppose to change color depending on what I choose. For example when the cell says "Not started" it should turn red. People have advised me to do conditional formatting, however, I find that it doesn't work after I update the model. So, I have to use VBA.
The code I use is:

VBA Code:
For i = 1 To lr
If Cells(i, "C") = "Not started" Then
 Cells(i, "C").Font.Color = vbBlack
 Cells(i, "C").Interior.Color = 10329075
 End If

It works, but just not automatically.

Does anybody know what I am talking about and could help me out?

Thanks :)

Even
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
You can use event Worksheet_Change to automatically trigger your macro whenever you change the cell's contents to "Not started". Use this to be pasted in the sheet's module:
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("C:C")) Is Nothing Then Exit Sub
    If Target.CountLarge > 1 Then Exit Sub
    If Target = "Not started" Then
        Target.Font.Color = vbBlack
        Target.Interior.Color = 10329075
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top