如何取相同项的最后一次值

来源:互联网 发布:python csv 编辑:程序博客网 时间:2024/05/16 08:18

示例说明:A列是料号列,只需要取重复项的最后一行数据,例如B料号是取黄色行数据。

该实例可用于公司BOM表中取最近日期数据

 

源数据

源数据

 

 

结果

结果

VBA代码:

Sub test()Dim cn As Object, sql$Set cn = CreateObject("ADODB.Connection")Sheet2.[a1:d65536].ClearContentscn.Open "provider=microsoft.jet.oledb.4.0;" & _        "extended properties='excel 8.0;hdr=no';" & _        "data source=" & ThisWorkbook.FullNamesql = "select f1,last(f2),last(f3),last(f4) from [sheet1$] group by f1"Sheet2.[a1].CopyFromRecordset cn.Execute(sql)cn.CloseSet cn = NothingEnd Sub

http://blog.csdn.net/laoyebin/article/details/5293142

0 0