Hi,
I started recently to learn VBA and I need some help with changing the font color of a value inside a text box based on condition. I tried below macro but it changed the text box color instead of the font. Can anyone help?
I started recently to learn VBA and I need some help with changing the font color of a value inside a text box based on condition. I tried below macro but it changed the text box color instead of the font. Can anyone help?
Code:
Sub Set_Color_TextBox()
ActiveSheet.Shapes.Range(Array("D_2018")).Select
If ActiveSheet.[Cell_Delta].Offset(1, 0).Value < 0 Then
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
.Solid
End With
Else
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(146, 208, 80)
.Transparency = 0
.Solid
End With
End If
ActiveSheet.Shapes.Range(Array("D_2017")).Select
If ActiveSheet.[Cell_Delta].Offset(2, 0).Value < 0 Then
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
.Solid
End With
Else
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(146, 208, 80)
.Transparency = 0
.Solid
End With
End If
ActiveSheet.Shapes.Range(Array("D_2016")).Select
If ActiveSheet.[Cell_Delta].Offset(3, 0).Value < 0 Then
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
.Solid
End With
Else
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(146, 208, 80)
.Transparency = 0
.Solid
End With
End If
End Sub
Last edited by a moderator: