![]() but that will run every time the sheet is recalculated. To do that, you would need to use the worksheet calculate event like this: ![]() Note: the above will not fire if the values change during recalculation, for example if you enter =A1 in cell E7, when you change the value of A1, the above code does not run. 'MsgBox "Chart object can not be found in the active sheet", vbCritical Set ch = ActiveSheet.ChartObjects(1).Chart If Intersect(Union(rngData, rngGoal), Target) Is Nothing Then Exit Sub Set rngGoal = Range("E9") '# Set the address of the Goal here # Set rngData = Range("E4:E7") '# The plotted range of values # Private Sub Worksheet_Change(ByVal Target As Range)ĭim ch As Chart, ser As Series, pt As Pointĭim i As Long, rngData As Range, rngGoal As Range ![]() Please try this (it has an error catch so it wont run if there is not a chart in the worksheet): Sorry, there was a slight error in the code I posted before. Fig.4),4), then select Scatter with Straight Lines and Markers option. Click on the Insert tab, and select the Scatter option in the Charts area (see Fig. Since we are using the worksheet change event, the macro has to go in the Sheet module for the sheet which you want it to run on. Highlight all of your data and column labels by left-clicking in cell A1, holding the button down, and then dragging the cursor down and to the right to cell E29. ![]() Did you "Right-click on the sheet's tab and click View Code" then paste the macro there?
0 Comments
Leave a Reply. |