简体   繁体   English

Excel - 将值与相应的列匹配,检查值并删除行

[英]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 值列表,其中包含PartNoRev

I need to shrink my list down by deletion, leaving each PartNo and Rev at the highest Rev number.我需要通过删除来缩小我的列表,将每个PartNoRev保留在最高的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.

相关问题 如何匹配多个列值并在Excel中提取相应的单元格值 - How match multiple column values and extract corresponding cell values in Excel Excel:对应单元格中匹配特定值的行的列中的总和 - Excel: Sum Values in a Column for Rows Where a Particular Value is Matched in a Corresponding Cell 如果语句要检查Excel列中的匹配值 - If Statement to check Excel column for a match value 匹配 80k 行的 excel 工作簿中的两列值,然后将名称写入新工作表和第三列中的相应值。 还可以获取最新日期 - match two column value in excel workbook of 80k rows then write name to new sheet and corresponding value from 3rd column. Also grab latest dates 如何自动删除与 Excel 中的特定值不匹配的行? - How to automatically delete rows that don't match a specific value in Excel? 匹配列中的字符串并对相应的行求和 - Match string in column and sum corresponding rows 在VBA中通过查找列和列中的值来删除Excel中的行 - Delete rows in Excel using VBA by finding column and value within column excel唯一值:查找没有相应匹配项的行 - excel unique value: Find rows which doesn't have a corresponding match 使用另一张工作表中的列中的值从excel中删除行? - Delete rows from excel using values from a column in another sheet? 如何使用列值删除基于Excel工作表的行 - How to delete the rows based in excel sheet using column values
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM