在Excel中为单个单元添加两种颜色
是否可以在一个单元格中填充两种颜色?
(例如:红色的A1细胞的一半,绿色的A11细胞的另一半)
这可以使用
格式单元格>填充标签>填充效果
select
两种颜色(select你的颜色)
使用颜色渐变,下面的代码是从本网站采取的,它将有希望的帮助:
http://software-solutions-online.com/2014/04/09/excel-vba-gradients-colors/
Sub Example1_a() Dim objColorStop As ColorStop Dim lngColor1 As Long 'creates the gradient in cell A1 Range("A1").Interior.Pattern = xlPatternLinearGradient 'changes its orientation Range("A1").Interior.Gradient.Degree = 90 'gets the color code for the second colorstop object lngColor1 = Range("A1").Interior.Gradient.ColorStops(2).Color 'clears the previous colostop objects Range("A1").Interior.Gradient.ColorStops.Clear 'creates a colorstop object with the position 0 Set objColorStop = Range("A1").Interior.Gradient.ColorStops.Add(0) 'changes its color to green objColorStop.Color = vbGreen 'creates a colorstop object with the position 1 Set objColorStop = Range("A1").Interior.Gradient.ColorStops.Add(1) 'changes its color to red objColorStop.Color = lngColor1 End Sub