Conditional formatting based on several cell values

alecambo

New Member
Joined
Apr 10, 2015
Messages
35
Office Version
  1. 2021
Platform
  1. Windows
Good day! I have dataset that looks like this (let's assume that "Name" is column A and "Sequence" is column B):
NameSequence
BUNNY1
BUNNY2
BUNNY3
BUNNY4
TIGER1
TIGER2
TIGER3
TIGER-
DOG
4
DOG
3
DOG
1
DOG
2

<tbody>
</tbody>

I am in the need of a simple formula highlights the 4 "Sequence" cells in red when the sequence for each "Name" is any different from the two following sequences: "1 ,2, 3, 4" or "1, 2, 3, -": in the given example, DOG should turn red since the sequence is different from the two allowed ones.

Thanks in advance,

Alejandro
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Will there always be four numbers for each animal?
If not, what happens if you get this sequence

BUNNY 1
BUNNY 1
BUNNY 2
BUNNY 3
BUNNY 4

I see TWO four number sequences, the 1234 you've stated starting at row 2 and 1123 starting at row 1
1123 is not a valid sequence so should that be highlighted?
 
Last edited:
Upvote 0
Will there always be four numbers for each animal?
If not, what happens if you get this sequence

BUNNY 1
BUNNY 1
BUNNY 2
BUNNY 3
BUNNY 4

I see TWO four number sequences, the 1234 you've stated starting at row 2 and 1123 starting at row 1
1123 is not a valid sequence so should that be highlighted?

You are correct, there will always be four numbers for each animal.
 
Upvote 0
We can do this with a helper column, there may be a way with array formulas to avoid the helper column, though I cant see it at the moment.

in C2
=(COUNTIF(A$2:A2,A2)=B2)*1
and copy down the column

Then
Select the range to highlight

Conditional Formatting
New Rule
Use a formula to determine...

=AND(A2<>"",SUMIF(A$2:A$1000,A2,C$2:C$1000)=4)

Format as red
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,044
Members
448,543
Latest member
MartinLarkin

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