|
谢谢老师,我上传的附件总是审核不过去。
再请教您一下
1、我把a1改成b5,即要从b5开始粘贴,但总是报错
zwb.Sheets(d(k)).[a1].Resize(UBound(arr), UBound(arr, 2)) = arr
2、或如原文件从B5开始开始复制,应怎么写?
谢谢!
Sub ykcbf() '//2023.4.21
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim arr, brr, d, p, f
Set d = CreateObject("Scripting.Dictionary")
Dim tm: tm = Timer
a = [{"214","SA"}]
b = [{"214","216"}]
For i = 1 To 2
d(a(i)) = b(i)
Next
Set zwb = ThisWorkbook
p = ThisWorkbook.Path & "\"
f = Dir(p & "*.xls*")
Do While f <> ""
For Each k In d.keys
If InStr(f, k) Then
With Workbooks.Open(p & f, 0)
arr = .Sheets(1).UsedRange
.Close False
End With
zwb.Sheets(d(k)).[a1].Resize(UBound(arr), UBound(arr, 2)) = arr
Exit For
End If
Next
f = Dir
Loop
Application.ScreenUpdating = True
MsgBox "运行完毕,共用时: " & Format(Timer - tm, "0.000秒"), , "提示"
End Sub
|
|