title: VBA: set gradient fill background angle
body: <p>I have the following problem: I want to set a chart background with "Gradient Fill" and change the angle with a macro.</p>
  
  <p>Recording a Macro does not help. The only thing I got is the following:</p>
  
  <pre><code>    With Selection.Format.Fill
      .Visible = msoTrue
      .ForeColor.RGB = RGB(255, 117, 117)
      .BackColor.RGB = RGB(0, 203, 92)
      .TwoColorGradient msoGradientDiagonalUp, 1
  End With
  </code></pre>
  
  <p>In reality I want to set the colors in advance and use the macro just for orientation. The only thing the macro should do is:</p>
  
  <pre><code>If variable = A then 'select the chart and set angle to 45%
  If variable = B then 'select the chart and set the angle to 135%
  </code></pre>
  
  <p>and so on.</p>
  
  <p>I do not want to set manually the colors because I will have 4 colors and it useless to set them every time since their relative position is always the same within the gradient pattern.</p>
  
  <p>Any Idea?</p>