Conditional formatting

numaiu

New Member
Joined
Jul 16, 2018
Messages
3
Hello.

I want to make a table that autoamticly changes the row's background color/text color every time the text from the first column changes.
It should look like this:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]aaa
[/TD]
[TD]row bg color/text color: grey
[/TD]
[/TR]
[TR]
[TD]aaa
[/TD]
[TD]row bg color/text color: grey
[/TD]
[/TR]
[TR]
[TD]555
[/TD]
[TD]row bg color/text color: red
[/TD]
[/TR]
[TR]
[TD]tttt
[/TD]
[TD]row bg color/text color: grey
[/TD]
[/TR]
[TR]
[TD]tttt
[/TD]
[TD]row bg color/text color: grey
[/TD]
[/TR]
[TR]
[TD]tttt
[/TD]
[TD]row bg color/text color: grey
[/TD]
[/TR]
[TR]
[TD]1212
[/TD]
[TD]row bg color/text color: red
[/TD]
[/TR]
[TR]
[TD]1212
[/TD]
[TD]row bg color/text color: red
[/TD]
[/TR]
[TR]
[TD]tttt
[/TD]
[TD]row bg color/text color: grey
[/TD]
[/TR]
[TR]
[TD]tttt
[/TD]
[TD]row bg color/text color: grey
[/TD]
[/TR]
</tbody>[/TABLE]

Can this be done ?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Welcome to the Board!

One way would be to use a "helper" column (which you can hide of you want).
Let's say that your data starts in cell A1.
Then in B1, you could enter 1.
Then in B2, enter this formula:
Code:
=IF(A2=A1,B1,B1+1)
and them copy down for all rows.

Then, you could use highlight cells A1 to the bottom, and use these Conditional Formatting formulas:

Condition 1
=ISODD($B1)
choose grey color

Condition 2
=ISEVEN($B1)
choose red color

This should do what you want.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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