|
楼主 |
发表于 2016-6-23 00:23
|
显示全部楼层
本帖最后由 hyjianjian 于 2016-6-23 00:28 编辑
zax010:
如何对输出结果 F列 去重复?
对输出结果既(ar(i, 6)) F列 如有重复只显示一条。
图片中,sheet2 F列涂色为重复(并非单纯 sheet2 工作表 整列去重复! 而是对应匹配F列搜索输出的值去重复!)
恳请协助,谢谢!- Sub zax010()
- Dim ar, br, mb, wb As Workbook
- mb = Sheet1.[a1].CurrentRegion
- Application.ScreenUpdating = False
- Sheet2.Activate
- Cells.Clear
- Set wb = Workbooks.Open(ThisWorkbook.Path & "\1.xls")
- With wb
- lr = .Sheets(1).Range("A65536").End(3).Row
- ar = .Sheets(1).Range("A2:V" & lr)
- .Close False
- End With
- For w = 2 To UBound(mb)
- ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
- br(1, 1) = mb(w, 1): m = 1
- For i = 1 To UBound(ar)
- If ar(i, 6) = mb(w, 1) And ar(i, 10) > 0 Then
- k = i: m = m + 1
- For x = k To 1 Step -1
- If ar(x, 3) = 0 Then
- For j = 1 To UBound(br, 2)
- br(m, j) = ar(x, j)
- br(m, 1) = ar(i, 10)
- br(m, 2) = ar(i, 7)
- br(m, 3) = ar(i, 8)
- Next
- Exit For
- End If
- Next
- End If
- Next
- Sheet2.Cells(2 + n, 1).Resize(m, UBound(br, 2)) = br
- n = n + m + 1
- Next
- Cells.EntireColumn.AutoFit
- Application.ScreenUpdating = True
- End Sub
复制代码
|
-
|