|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 合并()
Application.ScreenUpdating = False
Dim ar As Variant
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
Dim br()
ReDim br(1 To 50000, 1 To 2)
f = Dir(ThisWorkbook.Path & "\*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & f, 0)
With wb.Worksheets(1)
rs = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a1:b" & rs)
End With
wb.Close False
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" And Trim(ar(i, 2)) <> "" Then
t = d(Trim(ar(i, 1)))
If t = "" Then
k = k + 1
d(Trim(ar(i, 1))) = k
t = k
br(k, 1) = ar(i, 1)
End If
br(t, 2) = br(t, 2) + ar(i, 2)
End If
Next i
End If
f = Dir
Loop
With Sheet1
.[a1].CurrentRegion.Offset(1).Clear
.[a2].Resize(k, 2) = br
.[a2].Resize(k, 2).Borders.LineStyle = 1
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
评分
-
1
查看全部评分
-
|