Excel-VBA gradient colorstops -


What is the best way to apply a horizontal gradient fill effect through a macro code from a cell?

I wanted to set up in Excel shield (right-click on cell B1, format cell ..., fill, fill effects, two-color, horizontal, "right" at all).

Then I have the following to figure out how the code is represented by the code. When I step through the code, I shield and myrange object of colorstops can use the Locals window to observe:

  as determined dim myrange limit myrange = ActiveSheet.range ("B1")  

Using this information, I can now work hard in a macro, in order to duplicate the gradient in the code:

  'First, delete myrange.Interior.Gradient.ColorStops cs.Delete next in each CS' then for anyone Minister's shield colorstops, Kadd allocated colorstops desired slope with myrange.Interior.Gradient.ColorStops color = 16777215 Status = 0 ThemeColor = 1 TintAndShade = 0 .add color = 7,961,087 position = 0.5 ThemeColor = 0 TintAndShade = 0 .add color = 16,777,215 status = 1 ThemeColor = 1 TintAndShade = 0  ends with 

Unfortunately, the result is something that looks completely wrong. The most obvious thing is that the shield is in black and white, yet I adjust the RGB values.

Is there anything else that should be added here?

The assignment of color stops is not a valid code. You have to add a color palette and then have to set their properties. The macro recorder does it correctly.

  Set the set myrange limit to the sub SetGradient () myrange = ThisWorkbook.Sheets ("Sheet1"). Range ( "B myrange.Interior .Pattern with 1") = xlPatternLinearGradient .Gradient.Degree = 90 myrange.Interior.Gradient.ColorStops.Add with .Gradient.ColorStops.Clear end (0) .color = 16,777,215 .TintAndShade = with 0 with myrange.Interior.Gradient.ColorStops.Add with the end (0.5) myrange.Interior.Gradient.ColorStops.Add (1) with .color = 7961087 .TintAndShade = 0 .color = 16,777,215 .TintAndShade = 0 End HTML with End Sub  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -