Hi everyone,
I am currently battling with a piece of code.
I have a shape named "cutshp".I want it to be either red or green depending on whether the value of a cell (q4) is higher or lower than zero.
I want a particular type of gradient fill and shade of red and green. For some reason I can't get this to work for me:
any solutions would be greatly appreciated.
Many thanks
I am currently battling with a piece of code.
I have a shape named "cutshp".I want it to be either red or green depending on whether the value of a cell (q4) is higher or lower than zero.
I want a particular type of gradient fill and shade of red and green. For some reason I can't get this to work for me:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With ActiveSheet.Shapes("CustShp")
If Range("q4").Value >= 0 Then
.Fill.ForeColor.RGB = RGB(209, 40, 46)
.BackColor.RGB = RGB(157, 30, 35)
.TwoColorGradient Style:=msoGradientDiagonalUp, Variant:=1
ElseIf Range("q4").Value <= 0 Then
.Fill.ForeColor.RGB = RGB(77, 157, 87)
.BackColor.RGB = RGB(58, 118, 65)
.TwoColorGradient Style:=msoGradientDiagonalUp, Variant:=1
End If
End With
End Sub
any solutions would be greatly appreciated.
Many thanks