返回列表 上一主題 發帖

[發問] 檢查重複性質的資料

  1. Sub ex()
  2. Set d = CreateObject("Scripting.Dictionary")
  3. With 工作表1
  4.    For Each a In .Range(.[A1], .[A1].End(xlDown))
  5.       mystr = a & a.Offset(, 1) & a.Offset(, 2) & a.Offset(, 4)
  6.       If d.exists(mystr) Then MsgBox a & "資料重複"
  7.       d(mystr) = Application.Transpose(Application.Transpose(a.Resize(, 6).Value))
  8.    Next
  9. End With
  10. With 工作表2
  11. .Cells.ClearContents
  12. .[A1].Resize(d.Count, 6) = Application.Transpose(Application.Transpose(d.items))
  13. End With
  14. End Sub
複製代碼
回復 5# jackyliu
學海無涯_不恥下問

TOP

        靜思自在 : 不要小看自己,因為人有無限的可能。
返回列表 上一主題