返回列表 上一主題 發帖

[發問] Dictionary之下,兩個Excel欄位聯合 作為判別條件

  1. Sub Ex()
  2.     Dim D As Object, R As Range
  3.     Set D = CreateObject("Scripting.Dictionary")
  4.     With Sheet1
  5.         For Each R In .Range(.Cells(2, 3), .Cells(65536, 4).End(xlUp)).Rows
  6.             D(R.Cells(1) & R.Cells(2)) = R
  7.         Next
  8.     End With
  9.     If D.Count = 0 Then Exit Sub
  10.     With ListBox1
  11.         .ColumnCount = 2
  12.         .List = Application.Transpose(Application.Transpose(D.items))
  13.     End With
  14. End Sub
複製代碼

TOP

        靜思自在 : 君子為目標,小人為目的。
返回列表 上一主題