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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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