2

I want to apply two colors to one cell and separate them diagonally. I know that there is a function to add gradients in Excel, but I haven't found a way to set the strength of the color stop.

The first cell is what it looks like now and the second one is what I need

3
  • I don't believe it's possible without using complicated VBA...
    – Kinnectus
    Oct 22, 2018 at 7:35
  • @Kinnectus, I would love to know how it could be achieved, even if that means use of complicated VBA, please! Oct 25, 2018 at 0:39
  • @BharatAnand just letting you know that I was able to achieve it. I posted an answer myself.
    – Victor O
    Oct 25, 2018 at 18:11

3 Answers 3

3

So after playing around a little bit, I figured out how to do it. My mistake was that I only added two color stops, when I should've added 4 color stops, in order to remove the color gradient. The gradient is being automatically added to create a smooth color transition between two colors. If you make the color stop distance between two colors as small as possible, you won't see a color gradient.

Here is my code:

With Selection.Interior
    .Pattern = xlPatternLinearGradient
    .Gradient.Degree = 225
    .Gradient.ColorStops.Clear
End With

With Selection.Interior.Gradient.ColorStops.Add(0)
    .Color = RGB(255, 0, 0)
    .TintAndShade = 0
End With

With Selection.Interior.Gradient.ColorStops.Add(0.49999999)
    .Color = RGB(255, 0, 0)
    .TintAndShade = 0
End With

With Selection.Interior.Gradient.ColorStops.Add(0.5)
    .Color = RGB(0, 255, 0)
    .TintAndShade = 0
End With

With Selection.Interior.Gradient.ColorStops.Add(1)
    .Color = RGB(0, 255, 0)
    .TintAndShade = 0
End With

And here is how it looks like: Two colored Excel cell

1

Create an image in Photoshop or similar, resize and insert into cell.

2
  • I already solved the problem programmatically. Using images would not allow me to specify the colors dynamically.
    – Victor O
    May 17, 2020 at 4:09
  • This is a suitable alternative to using VB or programming, you can even do it in MS Paint!
    – JDuarteDJ
    Nov 15, 2022 at 14:16
0

Easiest method is to insert triangular shapes into the cell and colour them as you please. You can then harden the border with either the shape control or use the cell border control. Ta Dah!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .