Tandar - - Latest reply:
ac3mark

- Posts
- 10940
- Registration date
- Monday June 3, 2013
- Status
- Moderator
- Last seen
- December 14, 2018

Related:

- Excel vba change cell color based on value
- Vba highlight cell - Best answers
- Excel vba change cell background color based on value - Best answers
- Changing a cell value based on the color of a ✓ - Forum - Office Software
- Conditional formatting: change fontcolor based on another cell ✓ - Forum - Excel
- Change color to different cells based on another cells text. ✓ - 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 value - Forum - Excel

Best answer

TrowaD

- Posts
- 2440
- Registration date
- Sunday September 12, 2010
- Status
- Contributor
- Last seen
- December 13, 2018

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

A few words of thanks would be greatly appreciated. Add comment

has helped 2884 users this month

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!