Reputation: 387
I have a list of items, each with its own code, that I would like the user to rank in an arbitrary order of preference 1st to 5th. Not all items need to be ranked. However, each item should only be ranked ONCE (no duplicates). My sample table of records is as follows:
ID 1st 2nd 3rd 4th 5th 1 U74 L65 G56 N28 M82 2 N28 A11 L65 P37 L65 3 H72 R99 B42 Y95 G56 4 T63 C58 P37 B42 C58
(In this instance, user ID 2 and 4 have duplicate codes L65 and C58 respectively)
Checking and highlighting duplicate codes in a single row is easily done with conditional formatting. The problem I'm running into is how to "copy" the formatting to the rest of the rows. My actual dataset has over 300 records, so doing it manually for each row is not really an option.
Upvotes: 1
Views: 1915
Reputation: 19727
If you have a data like this:
You just need to use this formula: =COUNTIF($B2:$F2,B2)>1
Of course you need to use Use a formula to determine which cell to format
as a rule type:
And also you need to define where you'll apply the formatting ($B$2:$F$5
in our example).
Or you can select the entire range you want to format before actually adding the Conditional Format
The result would be:
Is this what you're trying?
Edit1: How it works? (for zipzit)
Let us examine the formula: =COUNTIF($B2:$F2,B2)>1
Which we applied in: $B$2:$F$5
Regular formula in Excel Cells behaves the same way when used in Conditional Formatting.
So absolute and relative cell address (with $
and without $
) applies to it as well.
So if we apply the formula for example in B2
only, it will evaluate how many occurrence does the value in B2
have in $B2:$F2
using COUNTIF
formula.
The answer is 1. In our formula, you'll only format it if it is >1
.
Now say we copy it in C2
.
Notice that B2
in our formula use relative referencing both on rows and column.
So instead of evaluating B2
again against $B2:$F2
, it will evaluate C2
.
Now, to make sure it will evaluate it against the same set of range $B2:$F2
, notice that we precede the column address with $
.
I have other post about Conditional Formatting which you might want to check out.
Upvotes: 2
Reputation: 3997
Ouch, you are right. There appears to be no easy way to copy the format to more than one row at a time. I've tried many different versions of the F4 trick, to no avail.
You're not going to like this answer, but I'd do it via macro, copy all the data to a new sheet tab, count the number of rows, then loop from top to bottom using a row pointer and paste "format only" one line at a time via the macro. Its not romantic, but it will work.
Another way to do it is to trick the code so you can do a math review (e.g.
vote #1 = 00000001 (U74) vote #00000010 (L65) vote #00000100 (G56) vote#00001000 (N28) vote#00010000 (M82) ... etc...
that way you'd just add the votes, and you should see 01011101
for a result. If you see 10021100
you immediately know there is a repeat. Not sure how many choices your folks have to vote for... You could actually do this with binary numbers (expressed as digital #'s then use Dec2Bin conversion on the sum to quickly see the result)
Upvotes: 0