Having a little problem with .GradientStops

Launayvolone

New Member
Joined
Nov 26, 2020
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hey,
So i wrote a macro that changes my points color based on their values. But once i want to apply a gradient to some of them : everything breaks.
I know that choose the color of a gradient stop you should use .GradientsStop.Insert RGB(....) but it doesn't seem to be working with me.

Thank's for your time.

Here is my code :
VBA Code:
Sub CodeCouleur()
 Dim s As Series
 Dim i As Long
 Dim g As Long
 Dim pt As Point
 
 g = 0
 T = 0

 
 Sheets(12).ChartObjects(1).Select
 With ActiveChart
 For Each s In .SeriesCollection
 For i = 1 To s.Points.Count
 Set pt = s.Points(i)
 If Cells(10 + i, 9 + g).Value >= 1.1 Then
 s.Points(i).MarkerBackgroundColor = RGB(237, 125, 49)
 ElseIf Cells(10 + i, 9 + g).Value <= 1.1 And Cells(10 + i, 9 + g).Value >= 0.3 Then
 With pt.Format.Fill
 .ForeColor.RGB = RGB(0, 128, 128)
 .OneColorGradient msoGradientVertical, 1, 1
 .GradientStops.Insert RGB(237, 125, 49)
 End With
 ElseIf Cells(10 + i, 9 + g).Value <= 0.3 And Cells(10 + i, 9 + g).Value >= -0.3 Then
 s.Points(i).MarkerBackgroundColor = RGB(191, 191, 191)
 ElseIf Cells(10 + i, 9 + g).Value >= -1 And Cells(10 + i, 9 + g).Value <= -0.3 Then
 With pt.Format.Fill
  .ForeColor.RGB = RGB(37, 64, 98)
  .OneColorGradient msoGradientVertical, 1, 1
  .GradientStops.Insert RGB(37, 64, 98), 0.5
 End With
 ElseIf Cells(10 + i, 9 + g).Value <= -1.1 Then
 s.Points(i).MarkerBackgroundColor = RGB(37, 64, 98)
 End If
 
 
 Next i
 g = g + 1
 Next s
 
 End With
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

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