|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
有的工作表有密码保护,请先去除密码后测试“合并”代码:
Sub test()
Dim brr(1 To 100000, 1 To 10)
p = ThisWorkbook.Path & "\"
f = Dir(p & "*.xlsx")
Application.ScreenUpdating = False
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set sht = Workbooks.Open(p & f).Sheets(1)
Arr = sht.[a1].CurrentRegion
Workbooks(f).Close False
For i = 3 To UBound(Arr)
If Len(Arr(i, 1)) Then
m = m + 1
For j = 1 To 10
brr(m, j) = Arr(i, j)
Next
End If
Next
End If
f = Dir
Loop
Set sht = Nothing
If m Then
Range("a4:j" & Rows.Count).ClearContents
[a4].Resize(m, 10) = brr
End If
Application.ScreenUpdating = True
MsgBox "合并完成!"
End Sub
|
|