I want to create a scatter plot graph with conditional format.
Each point should have a color based on the amount of involvement
Also is it possible to create this without adding each point individually?
I want to create a scatter plot graph with conditional format.
Each point should have a color based on the amount of involvement
Also is it possible to create this without adding each point individually?
The usual starting point for conditional formatting of charts is this: https://peltiertech.com/conditional-...-excel-charts/ Would it be acceptable to implement something like that in your sheet?
Originally Posted by shg
Thanks for your reply
However if i would implement this solution I am not able to label each point in the graph as seen in the example.
Can you explain why not? I don't see anything that would prevent you from adding data labels to each data series or some other strategy for adding data labels.
Perhaps you can give me one example in my attached sheet so i can see if i understand correctly.
I cannot, because my older version of Excel (assuming you have upgraded to something way newer than the Excel 2003 currently shown in your profile) does not support using "values from cells" as data labels. Your current setup uses 4 data series, a single point for each data series, and a single data label (value from corresponding cell in column A) for that point. Using Peltier's approach, you will end up with a chart with 3 data series (multiple points or NA() values in each data series) from 3 helper columns that pulls from the original data based on involvement. Once you have set up the three data series as outlined in Peltier's tutorial, adding data labels with values from cells should be as easy as selecting each data series, adding the data labels, and specifying column A as the source for the data label text. Can I assume, since you've already added data labels in the current file that you are already familiar with how to add data labels to a data series?
Hello
With VBA?
Try this macro for the example posted
Let me know. Hello,![]()
Option Explicit Sub Like_Cells_Colors() Dim ur As Long, clr As Integer Dim vAddress As Range, i As Long, s As Long ur = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row - 1 Range("A2:A" & ur).Interior.ColorIndex = xlNone For i = 2 To ur If Cells(i, 2) < 6 Then clr = 3 ElseIf Cells(i, 2) >= 6 And Cells(i, 2) < 9 Then clr = 15 ElseIf Cells(i, 2) >= 9 Then clr = 4 End If Cells(i, 1).Interior.ColorIndex = clr Next i ' ActiveSheet.ChartObjects(1).Activate For s = 1 To ActiveChart.SeriesCollection.Count - 1 With ActiveChart.SeriesCollection(s) Set vAddress = ActiveSheet.Range(Split(Split(.Formula, ",")(0), "!")(1)) For i = 1 To vAddress.Cells.Count .Points(i).Format.Fill.ForeColor.RGB = ThisWorkbook.Colors(vAddress.Cells(i).Interior.ColorIndex) Next i End With Next s Cells(1, 1).Select End Sub
Mario
MS documentation on how to set data label value from cells
https://support.microsoft.com/en-us/...2-f467c9f4eb2d
Hello
I think is better
Let me know. Hello,![]()
Option Explicit Sub Like_Cells_Colors() Dim ur As Long, clr As Integer Dim vAddress As Range, i As Long, s As Long ur = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row - 1 Range("A2:A" & ur).Interior.ColorIndex = xlNone For i = 2 To ur If Cells(i, 2) < 6 Then clr = 3 ElseIf Cells(i, 2) >= 6 And Cells(i, 2) < 9 Then clr = 15 ElseIf Cells(i, 2) >= 9 Then clr = 4 End If Cells(i, 1).Interior.ColorIndex = clr Next i ' ActiveSheet.ChartObjects(1).Activate For s = 1 To ActiveChart.SeriesCollection.Count - 1 With ActiveChart.SeriesCollection(s) Set vAddress = ActiveSheet.Range(Split(Split(.Formula, ",")(0), "!")(1)) For i = 1 To vAddress.Cells.Count .Points(i).Format.Fill.ForeColor.RGB = ThisWorkbook.Colors(vAddress.Cells(i).Interior.ColorIndex) ActiveChart.SeriesCollection(s).DataLabels.Select With Selection.Format.Fill .Visible = msoTrue .ForeColor.RGB = ThisWorkbook.Colors(vAddress.Cells(i).Interior.ColorIndex) .Transparency = 0 .Solid End With Next i End With Next s Range("A2:A" & ur).Interior.ColorIndex = xlNone Cells(1, 1).Select End Sub
Mario
I am unfamilliar with macro's. Is this the only way? I tried to copy and paste the text, but when I change something it does not change in the graph.
Hello
Associate the macro with a button and click on it every time there is a change in the sheet.
It is possible to make the change automatic if the data will always be in columns A and B (I see to adapt the code and then publish it) but if you are unfamiliar with VBA it is best to stop here.
Hello,
Mario
Hello
This code is to be entered in the class module of the sheet concerned.
Any variation in the interval from A2 to C and the last line evaluated will bring about an adjustment of the Graph.![]()
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim ur As Long, clr As Integer Dim vAddress As Range, i As Long, s As Long ur = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row - 1 If Not Intersect(Target, Range("A2:C" & ur)) Is Nothing Then Application.ScreenUpdating = False Application.EnableEvents = False For i = 2 To ur If Cells(i, 2) < 6 Then clr = 3 ElseIf Cells(i, 2) >= 6 And Cells(i, 2) < 9 Then clr = 15 ElseIf Cells(i, 2) >= 9 Then clr = 4 End If Cells(i, 1).Interior.ColorIndex = clr Next i ' ActiveSheet.ChartObjects(1).Activate For s = 1 To ActiveChart.SeriesCollection.Count - 1 With ActiveChart.SeriesCollection(s) Set vAddress = ActiveSheet.Range(Split(Split(.Formula, ",")(0), "!")(1)) For i = 1 To vAddress.Cells.Count .Points(i).Format.Fill.ForeColor.RGB = ThisWorkbook.Colors(vAddress.Cells(i).Interior.ColorIndex) ActiveChart.SeriesCollection(s).DataLabels.Select With Selection.Format.Fill .Visible = msoTrue .ForeColor.RGB = ThisWorkbook.Colors(vAddress.Cells(i).Interior.ColorIndex) .Transparency = 0 .Solid End With Next i End With Next s Range("A2:A" & ur).Interior.ColorIndex = xlNone Application.EnableEvents = True Application.ScreenUpdating = True Cells(1, 1).Select End If End Sub
I am attaching your file with the inserted macro.
Let them know. Hello,
Mario
Peltier's approach to this doesn't use any macros, so, no, macros are not the only way. Often it is really a personal preference of programming language. If you don't like using VBA, go back to Peltier's tutorial, set up your three helper columns, point your chart to those three columns, then apply data labels to the three data series. If you have trouble with any of those steps, let us know where you are stuck and we'll help.I am unfamilliar with macro's. Is this the only way?
I got it to work with the data series!!!!
Now when I change the label for a data point and I also change the cell on which conditional format is applied, the label is set back to the original value.
How can I prevent this from happening?
I am unable to imagine what you have done that causes a data label in the chart to not accurately reflect the text of the cell the data label points to. Could you upload your latest file with your chart so we can see what you've done?
I attached an excel file with my problem. When I change involvement in stakeholder interest tab, the name in the graph changes.
Even though I linked the label to the specific name.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks