Multiple Conditions Macro to Color Change Text Color in a Text Box

zinah

Active Member
Joined
Nov 28, 2018
Messages
308
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have 4 ratings : Highly Engaged, Moderately Engaged, Barely Engaged, and Disengaged. What I need is to write a macro that change the text colors in a text box with conditions, and below macro works perfectly fine, however, I need to add another condition, which is "if BE (Barely Engaged) & DI (Disengaged) are more than 0.03 then turn the color to Red" and if BE & DI less than 0.03 then turn them to blue, otherwise make them black. How should I add this condition to below macro? or do you suggest another macro?



Sub Manager_Eng()
Dim t2Sht As Worksheet
Set t2Sht = Sheets("Themes_2")
t2Sht.Activate


Dim ME_shps As Variant, Me_shp As Shape
ME_shps = Array("HE", "ME", "BE", "DI")


For Each itm In ME_shps
Set Me_shp = ActiveSheet.Shapes(itm & "_AMS_18")
With Me_shp
If Val(.TextFrame.Characters.Text) / 100 < -0.03 Then
.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf Val(.TextFrame.Characters.Text) / 100 > 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

Thank you!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,196,309
Messages
6,014,589
Members
441,828
Latest member
cofracr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top