As mentioned by Joel E you can do this fill effects but that puts a gradient where the 1st color gradually becomes a different color. If you want to remove the blending you can use VBA. I was able to quickly accomplish this by recording
a macro that sets the format of a cell using fill effects. you should get code that looks like this.
Sub Macro1()
'
' Macro1 Macro
'
With Selection.Interior
.Pattern = xlPatternLinearGradient
.Gradient.Degree = 90
.Gradient.ColorStops.Clear
End With
With Selection.Interior.Gradient.ColorStops.Add(0)
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
With Selection.Interior.Gradient.ColorStops.Add(1)
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0
End With
End Sub
If you want to get rid of the blending add 2 ColorStops to the code like this. Note how the color now switches between 49% and 51% of the cell. I also removed the .TintAndShade lines as they are not important.
Sub Macro1()
'
' Macro1 Macro
'
With Selection.Interior
.Pattern = xlPatternLinearGradient
.Gradient.Degree = 90
.Gradient.ColorStops.Clear
End With
With Selection.Interior.Gradient.ColorStops.Add(0)
.ThemeColor = xlThemeColorDark1 'First Color
End With
With Selection.Interior.Gradient.ColorStops.Add(0.49)
.ThemeColor = xlThemeColorDark1 'First Color
End With
With Selection.Interior.Gradient.ColorStops.Add(0.51)
.ThemeColor = xlThemeColorAccent1 'Second Color
End With
With Selection.Interior.Gradient.ColorStops.Add(1)
.ThemeColor = xlThemeColorAccent1 'Second Color
End With
End Sub
A couple of final notes.
- If you are looking for a diagonal or vertical color separation simply change the .Gradient.Degree to the appropriate angle.
- 0 = Vertical
- 45= rising diagonal
- 135 = falling diagonal
- Try .Color instead of .ThemeColor with a line of code like this
- .Color = RGB(255, 206, 0)
- This makes it easy to get whatever color you want all you need are the RGB integer values. Look them up on line or using excel under the More Colors> Custom colors section.