|
楼主 |
发表于 2018-6-17 12:16
|
显示全部楼层
谢谢星光老师,我太小白了,在下列这串代码里,在哪里增加才有效呢?谢谢
Sub Openfile()
Dim 表 As String
Dim 开始列 As String
Dim 结束列 As String
Dim 开始行 As String
Dim 结束行 As String
Dim chazhi As Integer
Dim sumall As Integer
表 = Sheets("数据").Cells(2, 3).Value
开始列 = Sheets("数据").Cells(2, 4).Value
结束列 = Sheets("数据").Cells(2, 5).Value
开始行 = Sheets("数据").Cells(2, 6).Value
结束行 = Sheets("数据").Cells(2, 7).Value
chazhi = 结束行 - 开始行
sumall = 0
X1 = Asc(开始列) - 64
X2 = Asc(结束列) - 64
Dim X As Integer
X = X2 - X1
Dim Statrow As Integer
Statrow = 4
Dim aa As Single
Application.Calculation = xlAutomatic
Sheets("数据").Select
Sheets("数据").Range("a" & Statrow & ":AZ50000").Select
Selection.ClearContents
Dim keyword As String
keyword = "*.xls"
Call App_SearchSubFolder(keyword, True)
aa = Timer
On Error Resume Next
If UBound(strArr) > 0 Then
Dim Exc As New Excel.Application
For i = 0 To UBound(strArr) - 1
Exc.Workbooks.Open strArr(i)
Exc.Visible = False
Exc.Application.DisplayAlerts = False
Sheets("数据").Range(Cells(Statrow + sumall, 1), Cells(Statrow + sumall + chazhi, 1)) = strName(i)
'------------------------解密码,设置页脚---------------
'Sheets("数据").Range(Cells(Statrow + sumall, 2), Cells(Statrow + sumall + chazhi, 2 + X)).Value = Exc.Sheets(表).Range(Exc.Cells(Sheets("数据").Cells(2, 6).Value, X1), Exc.Cells(Sheets("数据").Cells(2, 7).Value, X2)).Value
'MsgBox 开始列 & 开始行 & ":" & 结束列 & 结束行 & "B" & (Statrow + sumall) & ":" & Chr(X + 1) & (Statrow + sumall + chazhi) & " " & Chr(X + 1)
Sheets("数据").Range("B" & (Statrow + sumall) & ":" & Chr(X + 1 + 64) & (Statrow + sumall + chazhi)).Value = Exc.Sheets(表).Range(开始列 & 开始行 & ":" & 结束列 & 结束行).Value
Exc.Quit
sumall = sumall + chazhi
Next
Exc.Quit
End If
MsgBox Timer - aa
End Sub |
|