Auto update/run VBA when cell is changed

chow81

New Member
Joined
Feb 14, 2023
Messages
4
Office Version
  1. 365
Can anyone help... I wrote some code to change the plot colors in a scatter chart based on defined criteria, but I need the macro to run automatically each time the cell range is changed. Currently the macro only works if I run it manually. I am new to VBA, am I missing something in the code?

Sub ColorDot()

Dim s As Series
Dim i As Integer

Set s = ActiveChart.FullSeriesCollection(1)

For i = 1 To s.Points.Count
If Cells(i + 2, 18) = "1" Then s.Points(i).Format.Fill.ForeColor.RGB = RGB(255, 7, 1)
If Cells(i + 2, 18) = "2" Then s.Points(i).Format.Fill.ForeColor.RGB = RGB(255, 200, 0)
If Cells(i + 2, 18) = "3" Then s.Points(i).Format.Fill.ForeColor.RGB = RGB(0, 110, 230)
If Cells(i + 2, 18) = "4" Then s.Points(i).Format.Fill.ForeColor.RGB = RGB(34, 229, 1)

Next i

End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
What is the cell range that you want to trigger your macro when it is changed? Are the changes made manually or through formulas in the range?
 
Upvote 0
What is the cell range that you want to trigger your macro when it is changed? Are the changes made manually or through formulas in the range?
Hello, the cell range I am targeting is R3:R18 and the changes to these particular cells come from a formula pulling data from another worksheet. For example: =IF(AND('Leadership Assessment'!$G$19="Few (0-50%)"),1,IF(AND('Leadership Assessment'!$G$19="Some (50-75%)"),2,IF(AND('Leadership Assessment'!$G$19="Most/All (75-100%)"),3,IF(AND('Leadership Assessment'!$G$19="All/More (Beyond 100%)"),4,""))))
 
Upvote 0
Are the changes to the Leadership Assessment worksheet that affect the formula cells in R3:R18 made manually or via formulas?

Manual changes can be addressed with a Worksheet_Change event macro setup to call your macro whenever pertinent cells on the Leadership Assessment sheet are changed. The alternative is to use a Worksheet_Calculate event macro on the embedded chart worksheet and call your macro each time a calculation occurs, but this may lengthen calculation time.
 
Upvote 0
Are the changes to the Leadership Assessment worksheet that affect the formula cells in R3:R18 made manually or via formulas?

Manual changes can be addressed with a Worksheet_Change event macro setup to call your macro whenever pertinent cells on the Leadership Assessment sheet are changed. The alternative is to use a Worksheet_Calculate event macro on the embedded chart worksheet and call your macro each time a calculation occurs, but this may lengthen calculation time.
Hi JoeMo they are made manually by selecting a response from a dropdown on the Leadership Assessment.
 
Upvote 0
Then you can probably use a Worksheet_Change event macro that is placed in the Leadership Assessment sheet. This will likely require that you make some changes to your Sub ColorDot macro. If you can post some representative data for the embedded chart worksheet and the Leadership Assessment worksheet using XL2BB you will increase your chances of getting some help with the event macro and and any necessary changes to ColorDot. XL2BB - Excel Range to BBCode
 
Upvote 0
Then you can probably use a Worksheet_Change event macro that is placed in the Leadership Assessment sheet. This will likely require that you make some changes to your Sub ColorDot macro. If you can post some representative data for the embedded chart worksheet and the Leadership Assessment worksheet using XL2BB you will increase your chances of getting some help with the event macro and and any necessary changes to ColorDot. XL2BB - Excel Range to BBCode
Unfortunately, my organization prevents me from downloading and it also blocks me from sharing internal files externally. Is there any chance you could help me based on what I provided above?
 
Upvote 0
I think that would take a larger investment of my time than I am able to provide.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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