Related:

- Excel vba change cell color based on value
- Vba highlight cell based on value - Best answers
- Excel vba - change cell color based on value ✓ - Forum - Office Software
- Change color to different cells based on another cells text. ✓ - Forum - Excel
- VBA: Color cells in table based on multiple condition ✓ - Forum - Excel
- VBA macro to color a range of cells based on value of other cell - Forum - Excel
- Excel vba change cell color based on another cell value - Forum - Excel

## 1 reply

TrowaD

- Posts
- 2829
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- November 22, 2021

Hi Tandar,

I'm a little confused comparing your story with your code.

Try this code and see if it yields the desired result:

Best regards,

Trowa

I'm a little confused comparing your story with your code.

Try this code and see if it yields the desired result:

Sub ChangeColor() lRow = Range("C" & Rows.Count).End(xlUp).Row Set MR = Range("C2:C" & lRow) For Each cell In MR If cell.Value = "Yes" Then cell.Interior.ColorIndex = 10 If cell.Value = "No" Then cell.Interior.ColorIndex = 3 Next End Sub

Best regards,

Trowa

Sub colortest()

Set MyPlage = Range("y6:y313")

For Each cell In MyPlage

Select Case cell.Value

Case Is = "Pilot*"

cell.EntireRow.Interior.ColorIndex = 0

Case Is = "Flying*"

cell.EntireRow.Interior.ColorIndex = 0

Case Else

cell.EntireRow.Interior.ColorIndex = 10

End Select

Next

End Sub

I need that all cells that contains Pilot or Flying in it woudl be white, and all other green. But it always marks everything green... I tried to put * of all sides but it still the same. Could some one help me please?

cell.Interior.ColorIndex=10

I guess he is assuming the OP has the knowledge of Case and such, considering they are asking about colors in VBA! I guess we should have assumed the OP had advanced programming logic!

Thanks for making that a much simpler solution Qwentar!