|
liulang0808版主,请教下,我按 字典实例-05.zip,在前面增加五列:序号、省、县、镇、村,公式要怎样修改?
Sub 按钮2_Click()
Set d = CreateObject("scripting.dictionary")
arr = Sheets("原始数据").[a1].CurrentRegion
Application.ScreenUpdating = False
ActiveSheet.UsedRange.ClearContents
[a1] = "客户姓名"
For j = 2 To UBound(arr)
If Not d.exists(arr(j, 1)) Then
r = Cells(Rows.Count, 1).End(3).Row + 1
d(arr(j, 1)) = r
Cells(r, 1) = arr(j, 1)
End If
If Not d.exists(arr(j, 2)) Then
c = Cells(1, Columns.Count).End(xlToLeft).Column + 1
d(arr(j, 2)) = c
Cells(1, c) = arr(j, 2)
End If
Cells(d(arr(j, 1)), Cells(d(arr(j, 2)))) = arr(j, 3) + Cells(d(arr(j, 1)), Cells(d(arr(j, 2))))
Next j
Application.ScreenUpdating = True
End Sub
|
|