[英]Excel - Match values with corresponding column, check value and delete rows
I have a (long) list of Excel values with columns PartNo
and Rev
我有一个(长)Excel 值列表,其中包含
PartNo
和Rev
列
I need to shrink my list down by deletion, leaving each PartNo
and Rev
at the highest Rev
number.我需要通过删除来缩小我的列表,将每个
PartNo
和Rev
保留在最高的Rev
编号。
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.有 1500 行我想这样做。
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.我建议你创建一个包含这个公式的临时辅助列,从第 2 行复制下来。注意它是一个数组公式,必须用 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.在我的示例中,C2:C100 是包含零件号的范围,而 C2:D100 包含修订号。 The formula will return the largest Rev number associated with C2.
该公式将返回与 C2 关联的最大 Rev 数。 It will return the same Rev number for all rows of the same part number.
它将为相同零件号的所有行返回相同的 Rev 号。 Therefore you can use Excel's filter functionality to remove duplicates, leaving you with the desired result.
因此,您可以使用 Excel 的筛选功能来删除重复项,从而获得所需的结果。
Sort by column A (ascending) and column B (descending = highest value first) at the same time.同时按 A 列(升序)和B 列(降序 = 最大值在前)排序。 So your data looks like:
所以你的数据看起来像:
(note the
Rev
is going from maximum to minimum value now) (注意
Rev
现在从最大值变为最小值)
Then use the Remove Duplicates feature to remove duplicates in column A. So you end up with:然后使用删除重复项功能删除 A 列中的重复项。所以你最终得到:
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.如果您需要使用 VBA 执行此操作,请使用宏录制器(并在录制时手动执行)以初步了解您的代码的外观。 After using the macro recorder you should read How to avoid using Select in Excel VBA before you continue.
使用宏记录器后,您应该在继续之前阅读如何避免在 Excel VBA 中使用选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.