|
刚在学字典,蓝桥玄霜的一个例子,不能理解(红线部分),还请各位高手不惜赐教,最好能够介绍一下:Sub cfz()Dim i&, Myr&, Arr, j&, aaDim d, k, t, m&, Arr1Set d = CreateObject("Scripting.Dictionary")Myr = Sheet1.[a65536].End(xlUp).RowArr = Sheet1.Range("a1:g" & Myr)For i = 2 To UBound(Arr) If Left(Arr(i, 2), 3) = "禾丰镇" Then d(Arr(i, 3)) = d(Arr(i, 3)) & i & "," ElseIf Left(Arr(i - 1, 2), 3) = "禾丰镇" Then d(Arr(i, 3)) = d(Arr(i, 3)) & i & "," End IfNextk = d.keyst = d.itemsReDim Arr1(1 To UBound(Arr), 1 To 2)For i = 0 To UBound(k) t(i) = Left(t(i), Len(t(i)) - 1) If InStr(t(i), ",") > 0 Then aa = Split(t(i), ",") For j = 0 To UBound(aa) m = m + 1 Arr1(m, 1) = k(i) Arr1(m, 2) = Arr(aa(j), 2) Next End IfNextSheet2.Activate[a:b].ClearContents[a2].Resize(UBound(Arr1), 2) = Arr1[a1].Resize(1, 2) = Array("姓名", "地址")End Sub
|
|