|
本帖最后由 Albert128 于 2017-4-10 21:57 编辑
- Public mysht, S(1 To 71, 1 To 12)
- Sub 合并()
- Sheet1.Range("B3:M10,R3:R10").ClearContents
- Sheet2.Range("B2:M72,R2:R72").ClearContents
- Sheet3.Range("B2:M72,R2:R72").ClearContents
- For Each mysht In Array("Selling", "Admin")
- Getfd (ThisWorkbook.Path) '当前代码文件所在的路径
- ThisWorkbook.Sheets(mysht).[B2:M72] = S
- Next mysht
- End Sub
- Sub Getfd(ByVal Pth)
- Set Fso = CreateObject("Scripting.filesystemobject")
- Set FF = Fso.getfolder(Pth)
- For Each f In FF.Files
- If InStr(Split(f.Name, ".")(UBound(Split(f.Name, "."))), "xl") > 0 Then
- If f.Name <> ThisWorkbook.Name Then
- Set wb = Workbooks.Open(f): Set Bname = ActiveWorkbook.Sheets(mysht)'由于<span style="background-color: rgb(255, 255, 255);">团购报表里没有工作表“</span>Admin”提示下标越界“
- If Not Bname Is Nothing Then
- Arr = ActiveWorkbook.Sheets(mysht).Range("B2:M72")
- For i = 1 To 71 Step 2
- For L = 1 To 12
- S(i, L) = S(i, L) + Arr(i, L)
- Next L
- Next i
-
- End If
- wb.Close False
- End If
-
- End If
-
- Next f
- End Sub
复制代码 请大师指教,怎么解决下标越界,谢谢!
|
|