简体   繁体   中英

Excel - Match values with corresponding column, check value and delete rows

I have a (long) list of Excel values with columns PartNo and Rev

I need to shrink my list down by deletion, leaving each PartNo and Rev at the highest Rev number.

Example of my data here
我的数据示例在这里

This is what I want to end up with
我想最终得到什么

There are 1500 rows that I'd like to do this on.

I suggest that you create a temporary helper column with this formula in it, copied down from row 2. Note that it is an array formula which must be confirmed with CTL+SHIFT+ENTER. The part number need not be in consecutive rows.

=MAX(IF($C$2:$C$100=$C2,$D$2:$D$100))

In my example C2:C100 is the range containing the part number and C2:D100 contains the Rev number. The formula will return the largest Rev number associated with C2. It will return the same Rev number for all rows of the same part number. Therefore you can use Excel's filter functionality to remove duplicates, leaving you with the desired result.

Sort by column A (ascending) and column B (descending = highest value first) at the same time. So your data looks like:

在此处输入图片说明 (note the Rev is going from maximum to minimum value now)

Then use the Remove Duplicates feature to remove duplicates in column A. So you end up with:

在此处输入图片说明

If you need to do this with VBA use the Macro Recorder (and do it manually while recording) to get a first idea of how your code could look like. After using the macro recorder you should read How to avoid using Select in Excel VBA before you continue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM