vba change gradient color in graph

hudan

New Member
Joined
Jun 6, 2019
Messages
7
Dear Excell Expert,
Im try to change my graph with gradient color using VBA. i do record VBA when changing color to gradient but i receive error notification as follows.

object doesn't support my property or method


i hereby send my VBA code .

Sub gradient()

'
' gradient Macro
'

'


ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.FullSeriesCollection(1).Select
ActiveChart.FullSeriesCollection(1).Points(1).Select
Selection.Format.ShapeStyle = msoShapeStylePreset75
ActiveChart.FullSeriesCollection(1).Points(2).Select
Selection.Format.ShapeStyle = msoShapeStylePreset77

ActiveChart.FullSeriesCollection(1).Points(3).Select
Selection.Format.ShapeStyle = msoShapeStylePreset74
End Sub



Please need your advice.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
My Excel version does not recognize the constants in your code. What version are you using? Windows or Mac?
Can you describe the steps you are taking to apply the gradient manually?
 
Upvote 0
i use Windows OS and Excel 2016. Good News i have already succeed to fill gradient color in my chart as follows.

Dim cht As Chart


Set cht = ActiveSheet.ChartObjects("Chart 2").Chart

'Change first bar chart series fill color using RGB "BLUE"
'Change Top Color
cht.SeriesCollection(1).Format.Fill.ForeColor.RGB = RGB(91, 155, 213)
'Change Bottom Color
cht.SeriesCollection(1).Format.Fill.BackColor.RGB = RGB(42, 75, 134)

'Determine the Type of Gradient for ex: Horizontal, vertical or corner
cht.SeriesCollection(1).Format.Fill.TwoColorGradient msoGradientHorizontal, 1
cht.SeriesCollection(1).Format.Fill.GradientStops(1).Position = 0
cht.SeriesCollection(1).Format.Fill.GradientStops(2).Position = 1
Change mid Color
cht.SeriesCollection(1).Format.Fill.GradientStops.Insert RGB(74, 118, 198), 0.5
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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