# Ranking of data based on multiple criteria

#### siddharthnk

##### New Member
Hi All,

I need help with an excel formula which will allocate serial numbers a set of numbers in a column. The data is as follows.

 YES/NO CODES SERIAL NO'S YES 12345 1 YES 12346 2 NO 12356 YES 12345 1 NO 12356 YES 12357 3 YES 12346 2 YES 12346 2 YES 12347 4 YES 12347 4

<tbody>
</tbody>

As you can see, the first column in a yes/no column which has only yes's and no's which are formulated based on certain other criteria based on information present in other cells in the same row. The second column consists of project codes.
What I need is a formula which will allocate serial numbers to the third column based on the combination of yes's and the codes. As you can see in the screenshot, any code which is repeated with a yes has the same serial number has the same serial number. The rows where there is a no in the first column needs to be blank. Also, the codes will not be sorted in ascending or descending order and will keep increasing every week.

### Excel Facts

To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

#### Oeldere

##### Well-known Member
Please explain how the serial no are related.

I don't see the concept.

#### siddharthnk

##### New Member
The serial numbers or the rank are related such that every time the same code appears with a yes, it should have the same rank / serial number. A particular code can appear with a "no" but as I said earlier it needs to be ignored and has to be blank.

#### jtakw

##### Well-known Member
Hi,

Yeah, but why is 12357 ranked 3, and 12347 ranked 4?

#### Oeldere

##### Well-known Member

Code:
``Yeah, but why is 12357 ranked 3, and 12347 ranked 4 [COLOR="#B22222"](twice)[/COLOR]?``

#### siddharthnk

##### New Member
Yes you are right, my bad. It should be the other way around.

##### MrExcel MVP

In C2 control+shift+enter, not just enter, and copy down:
Rich (BB code):
``````=IF(\$A2="Yes",IF(ISNUMBER(MATCH(B2,\$B\$1:B1,0)),VLOOKUP(B2,\$B\$1:C1,2,0),
SUM(IF(FREQUENCY(IF(\$A\$2:A2="yes",\$B\$2:B2),\$B\$2:B2),1))),"")
``````

#### siddharthnk

##### New Member

Thanks for the formula. When I apply it, I get a 4 after 2. The 3rd rank is missing.

 YES/NO CODES YES 12345 1 YES 12356 2 NO 13456 YES 12345 1 NO 13456 YES 12356 2 YES 12357 4 NO 13456 NO 13456 YES 12358 5

<colgroup><col style="width:48pt" span="3" width="64"> </colgroup><tbody>
</tbody>

##### MrExcel MVP

Thanks for the formula. When I apply it, I get a 4 after 2. The 3rd rank is missing.

 YES/NO CODES YES 12345 1 YES 12356 2 NO 13456 YES 12345 1 NO 13456 YES 12356 2 YES 12357 4 NO 13456 NO 13456 YES 12358 5

<tbody>
</tbody>

Control+shift+enter means press down the control and the shift keys at the same time while you the enter key. When done properly, Excel itself puts a pair of { and } around the formula.

#### siddharthnk

##### New Member
Thanks Aladin. The formula works! What if the colums are next to each other. I never mentioned the column names because they aren't next to each other. There might be a couple of columns between the yes/no column and code column. Does the formula work the same?

Replies
0
Views
338
Replies
9
Views
292
Replies
1
Views
422
Replies
4
Views
343
Replies
2
Views
248

1,141,720
Messages
5,708,090
Members
421,545
Latest member
TWR

### 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.

### Which adblocker are you using?

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

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