|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
我有一段工作簿合并的代码,现在的需求是要从第2行开始合并,然后有70多列,请高手指点一下,该怎么改
- <div class="blockcode"><blockquote>Sub zz()
- Dim ar, d As Object, fs(1000), f$, p$, n&, k, t, tt, r&, x(4)
- tt = Timer
- Set d = CreateObject("scripting.dictionary")
- p = ThisWorkbook.Path & ""
- f = Dir(p & "*.xlsx")
- Application.ScreenUpdating = False
- Do While f <> "" And f <> ThisWorkbook.Name
- n = n + 1
- fs(n) = f
- f = Dir
- Loop
- For ii = 1 To n
- Application.StatusBar = "Processing " & ii & " of " & n
- f = fs(ii)
- With GetObject(p & f).Sheets(1)
- r = .[a65536].End(3).Row
- ar = .Range("a1:f" & r).Value
- Workbooks(f).Close False
- For i = 4 To r
- If Len(ar(i, 2)) Then
- For j = 0 To 4
- x(j) = ar(i, j + 1)
- Next
- k = ar(i, 1)
- If Not d.exists(k) Then d(k) = x
- End If
- Next
- End With
- Next
- k = d.keys
- ReDim ar(1 To d.Count, 1 To 60)
- For i = 1 To d.Count
- t = d(k(i - 1))
- For j = 0 To 4
- ar(i, j + 1) = t(j)
- Next
- Next
- [a5:f1000].Clear
- [a4].Resize(1, 6).Copy
- [a4].Resize(d.Count, 6).PasteSpecial xlFormats
- [a4].Resize(d.Count, 5) = ar
- Set d = Nothing
- Application.CutCopyMode = 0
- Application.ScreenUpdating = True
- Application.StatusBar = False
- MsgBox "used " & Format(Timer - tt, "0.0s")
- End Sub
复制代码
|
|