Change Excel shape interior color and border color using VBA ColorIndex
VBA:
Sub change_shape_color()Dim shp As Shape
With ActiveSheet.Shapes("My_shape").OLEFormat.Object
Select Case .Interior.ColorIndex
Case 3
.Interior.ColorIndex = 43 'light green
.Border.ColorIndex = 10 'dark green
Case 43
.Interior.ColorIndex = 45 'light orange
.Border.ColorIndex = 46 'dark orange
Case Else
.Interior.ColorIndex = 3 'light red
.Border.ColorIndex = 30 'dark red
End Select
End With
End Sub
No comments:
Post a Comment