Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

rank Two criteria and desired number of large value without duplicate


I want to find the top example 30 items without duplicate data from column H and insert them into the table shown

The desired number is entered in the yellow cell

The only important point here is that at the end of each column there is an H number that should not be included in the calculations 

h38 h71 h93 and etc.

I went as far as possible but i want this:


if remove gender and fill code ranked by code and number

if remove code and fill gender ranked by gender and number

if fill both ranked by code & gender and number

if both is empty ranked by just number Now whatever is gender & code

I want the formula to work either without condition or with one condition or with two conditions



Kar2rost. In this Forum, you should NOT specify/define a mini-project (as you have above) and expect us to deliver the solution..

You've arranged your data so that it makes it hard to meet your desired outcomes. E.g. if your data rows contained information like the month,  you could use regular filtering (or advanced filtering to copy filtered data to another Iocation ), subtotals within tables or pivot tables to get real outcomes. It seems to me however that you don't want to move from your set data format (with orange rows say) . I certainly don't have time this week to show you other approaches, sorry.

Hope others can help you. 
John_Ru (rep: 3677) Jul 11, '22 at 6:03 pm
Add to Discussion

Answer the Question

You must create an account to use the forum. Create an Account or Login