在桌面新建excel文件,文件名命名为q 打开此文件,把你两个销售数据表格按你图中的格式,一个复制到q文件的Sheet1,另一个复制到Sheet2 ,注意要按你截图的格式,从第二排开始复制粘贴。 在桌面新建文本文档,将下列代码复制进去 Set objFSO = CreateObject("Scripting.FileSystemObject") path=objFSO.GetFolder(".").Path path1=path & "\q.xls" path2=path & "\q.xlsx" Set oExcel=CreateObject("Excel.Application") if objFSO.FileExists(path1) then Set oWb=oExcel.Workbooks.Open(path1) else Set oWb=oExcel.Workbooks.Open(path2) end if Set oSheet1=oWb.Sheets("Sheet1") Set oSheet2=oWb.Sheets("Sheet2") oExcel.DisplayAlerts=FALSE all_row1=oSheet1.UsedRange.Rows.Count+1 all_row2=oSheet2.UsedRange.Rows.Count+1 oSheet1.Cells(2,5).Value="此页不同订单号" oSheet1.Cells(2,6).Value="订单销售额" oSheet1.Cells(2,7).Value="支付时间" oSheet2.Cells(2,5).Value="此页不同订单号" oSheet2.Cells(2,6).Value="订单销售额" oSheet2.Cells(2,7).Value="支付时间" redim arr1(all_row1) redim arr2(all_row2) k=3 for i=3 to all_row1 arr1(i)=oSheet1.Cells(i,1).Value next for i=3 to all_row2 arr2(i)=oSheet2.Cells(i,1).Value next for i=3 to all_row1 Set oCell=oSheet2.UsedRange.Find(arr1(i)) if oCell is nothing then oSheet1.Cells(k,5).Value=arr1(i) oSheet1.Cells(k,6).Value=oSheet1.Cells(i,2).Value oSheet1.Cells(k,7).Value=oSheet1.Cells(i,3).Value k=k+1 end if next k=3 for i=3 to all_row2 Set oCell=oSheet1.UsedRange.Find(arr2(i)) if oCell is nothing then oSheet2.Cells(k,5).Value=arr2(i) oSheet2.Cells(k,6).Value=oSheet2.Cells(i,2).Value oSheet2.Cells(k,7).Value=oSheet2.Cells(i,3).Value k=k+1 end if next oWb.save wscript.sleep 100 oExcel.WorkBooks.Close wscript.sleep 600 oExcel.Quit wscript.sleep 200 msgbox "已完成" 保存并关闭文件,将文件后缀名改为vbs ,若不会改后缀名请百度。 运行此文件,提示"已完成"即可,打开q即可看见不同的订单号。 第二个问题参考楼上。