Hi,
I have this macro that should change the text color in a textbox with conditions:
- If value < 3% then change text color to red
- If value > 3% then change text color to blue
- Else color to black
The textbox names are : 2018_Delta, 2017_Delta, and 2016_Delta
The macro changes the font to blue instead of conditions I set, can you help please?
Sub Color_Change()
Dim t2Sht As Worksheet
Set t2Sht = Sheets("It would take")
t2Sht.Activate
Dim D_shps As Variant, Me_shp As Shape
D_shps = Array("2018", "2017", "2016")
For Each itm In D_shps
Set D_shp = ActiveSheet.Shapes(itm & "_Delta")
With D_shp
If .TextFrame.Characters.Text < -0.03 Then
.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf .TextFrame.Characters.Text > 0.03 Then
.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 255)
Else: .TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)
End If
End With
Next itm
End Sub
I have this macro that should change the text color in a textbox with conditions:
- If value < 3% then change text color to red
- If value > 3% then change text color to blue
- Else color to black
The textbox names are : 2018_Delta, 2017_Delta, and 2016_Delta
The macro changes the font to blue instead of conditions I set, can you help please?
Sub Color_Change()
Dim t2Sht As Worksheet
Set t2Sht = Sheets("It would take")
t2Sht.Activate
Dim D_shps As Variant, Me_shp As Shape
D_shps = Array("2018", "2017", "2016")
For Each itm In D_shps
Set D_shp = ActiveSheet.Shapes(itm & "_Delta")
With D_shp
If .TextFrame.Characters.Text < -0.03 Then
.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf .TextFrame.Characters.Text > 0.03 Then
.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 255)
Else: .TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)
End If
End With
Next itm
End Sub