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.
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Worf

Well-known Member
Joined
Oct 30, 2011
Messages
4,002
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?
 

hudan

New Member
Joined
Jun 6, 2019
Messages
7
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
 

Watch MrExcel Video

Forum statistics

Threads
1,101,903
Messages
5,483,622
Members
407,400
Latest member
Rakeforms

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top