I am trying to write a simple event code that will run when a format is changed. Essentially, when a cell format is changed to green I want to put a 1 in another cell.
I am assuming that your cell will turn green or not, based on a conditional formatting rule.
The format change itself will not register as an event but the sheet change that satisfies the CF rule will.
So for example......
Your CF rule to set a cell or a range of cells green is =A5>20 and your cell to receive the value 1 is B1.
You could code something like .....
Code:
Private Sub Worksheet_Change (ByVal Target As Range)
Application.EnableEvents = False
If Range("A5").Value > 20 Then
Range("B1").Value = 1
Else
Range("B1").Value = "" 'Or Whatever
End If
Application.EnableEvents = True
End Sub
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.