- 积分
- 557
- 明经币
- 个
- 注册时间
- 2016-2-25
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2016-4-4 22:48:34
|
显示全部楼层
Real_King 发表于 2016-4-4 21:17
我用的是C#,不过你提到的数组,完全可以以dataset的形式啊,读写比你以遍历单元格形式快得多
Sub 预算材料汇总()
Dim wb As Workbook, wk As Workbook, myfile$, s&
Dim i As Integer
Dim k As Integer
Dim arr
Application.ScreenUpdating = False
myfile = Dir(ThisWorkbook.Path & "\预算\*.xls")
s = 2
Do While myfile <> ""
If ThisWorkbook.Name <> myfile Then
s = s + 1
Set wb = Workbooks.Open(ThisWorkbook.Path & "\预算" & "\" & myfile)
Set wk = GetObject(ThisWorkbook.Path & "\预算" & "\" & myfile)
With wb.Sheets(1)
arr = wb.Sheets("主材清单").Range(Cells(7, 5), Cells(299, 5))
Cells(1, s) = wb.Sheets("封面").Cells(3, 1)
Range(Cells(2, s), Cells(297, s)).Value = arr
End With
ActiveWorkbook.CheckCompatibility = False
wb.Close False
End If
myfile = Dir
Loop
Application.ScreenUpdating = True
End Sub |
|