Change color of data points in a chart in excel using VBA

  Рет қаралды 18,111

Karina Adcock

2 жыл бұрын

00:40 Method 1: Change data point color based on categories
06:34 Method 2: Change data point color based on numbers
Sub color_dots()
Dim s As Series
Dim i As Integer
Set s = ActiveChart.FullSeriesCollection(1)
For i = 1 To s.Points.Count
If Cells(i + 1, 3) = "A" Then s.Points(i).Format.Fill.ForeColor.RGB = RGB(255, 80, 80)
If Cells(i + 1, 3) = "B" Then s.Points(i).Format.Fill.ForeColor.RGB = RGB(255, 153, 0)
If Cells(i + 1, 3) = "C" Then s.Points(i).Format.Fill.ForeColor.RGB = RGB(0, 128, 128)
Next i
End Sub
----------------------------------------------------------------------------------------------------------------
Sub color_dots()
Dim s As Series
Dim i As Integer
Set s = ActiveChart.FullSeriesCollection(1)
For i = 1 To s.Points.Count
s.Points(i).Format.Fill.ForeColor.RGB = Cells(i + 1, 4).DisplayFormat.Interior.Color
Next i
End Sub

Пікірлер: 20
@ricardopina6027
@ricardopina6027 Жыл бұрын
I spent an entire morning searching for exactly this directions on assigning a conditional formatting to represent a third value on a scattered chart. Super useful. Thank you
@SuperWhizy
@SuperWhizy 2 жыл бұрын
Thank you. Outstanding instructions; concise, thorough and methodically executed. Love how you commented the script as well.
@lingvoclub
@lingvoclub 11 ай бұрын
本当にありがとうございました! あなたは、インターネットの広大な面でexcelの最高の先生です!
@MrChrisd015
@MrChrisd015 Жыл бұрын
Absolutely brilliant. So much easier, and with fewer steps, than all the other methods I've seen on other forums.
@mikepike7063
@mikepike7063 4 ай бұрын
Brilliantly presented Karina , functional , concise results along the way , and lots of helpful tips to reduce macro generated code which is always excessive imho but each excess might be what people are looking for so no complaints. A* on everything and many thanks to you.
@mohieel-dinsaber6427
@mohieel-dinsaber6427 2 жыл бұрын
Hello, how do do the same but in a workbook with multiple worksheets. I mean how to pinpoint the column I want to use for the color scale, as there are multiple worksheets each with different columns. thanks in advance!!
@Mathematicalbello
@Mathematicalbello 11 күн бұрын
Beautiful and very instructive, thanks a 1000 times
@benjaminvanschoors1930
@benjaminvanschoors1930 5 ай бұрын
When i try to run the same code as you do at 3:34 I get the following error: Object variable not set (Error 91). Any idea what I do wrong?
@DebashishP82
@DebashishP82 4 ай бұрын
I get the same error
@rudicerny
@rudicerny Жыл бұрын
Thank you, very useful. There only few such instructions on net, even if this essential for effective data presentation, congratulation!
@anthonysingh-tf7vl
@anthonysingh-tf7vl Жыл бұрын
How to do this with data located in separate worksheet from the plot??
@seanbeers9217
@seanbeers9217 Жыл бұрын
This was very helpful. Thank you!
@mollym2000
@mollym2000 2 жыл бұрын
Karina, do you know if/how it is possible to have different data marker SHAPES in the same data series?
@TheQuesssito
@TheQuesssito Ай бұрын
i have the same question, do u know now??
@anthoneliassen7707
@anthoneliassen7707 Күн бұрын
@@TheQuesssito Yes, it quite simple actually. Here is an example: s.Points(i).MarkerStyle = xlMarkerStyleX Just search for vba charts markerstyle to find alternative markerstyles.
@dr.rohitmittal1270
@dr.rohitmittal1270 2 жыл бұрын
Thank You for such a useful information
@latenightrelaxing6679
@latenightrelaxing6679 Жыл бұрын
thank you for sharing, that helped me a lot!
@hshrestha2811
@hshrestha2811 4 ай бұрын
this is genius.
@suebkostick2040
@suebkostick2040 2 жыл бұрын
fantatsic!
@annathevlogger8361
@annathevlogger8361 2 жыл бұрын
Satamaika
Life hack 😂 Watermelon magic box! #shorts by Leisi Crazy
00:17
Leisi Crazy
Рет қаралды 79 МЛН
Don't look down on anyone#devil  #lilith  #funny  #shorts
00:12
Devil Lilith
Рет қаралды 46 МЛН
Когда отец одевает ребёнка @JaySharon
00:16
История одного вокалиста
Рет қаралды 13 МЛН
Good teacher wows kids with practical examples #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 12 МЛН
iphone designer studio📱🤣🤣
0:16
티곰
Рет қаралды 2,7 МЛН
The damaged battery head isrepaired. #Battery #Repair
0:21
Hak Hang
Рет қаралды 35 МЛН
Tesla Coil Testing #experiment #shorts
0:29
Light K
Рет қаралды 7 МЛН
Секретные процессоры!
0:27
CONSTRUCT PC
Рет қаралды 523 М.
Cómo pensaba que sería el iPhone 16 😭
0:12
Alan
Рет қаралды 2,7 МЛН
Hardware tools repair tool high performance tool
0:16
Hardware tools
Рет қаралды 4,3 МЛН
How to connect electrical wires with good contact #short
0:29
Tuan CT
Рет қаралды 23 МЛН