|
原帖由 kuilinq 于 2011-6-4 00:34 发表
希望楼主能帮忙用EXCEL4宏函数来修改.......小弟将十分感谢!
不知道楼主测试过没有,不管是ado,还是数组公式,还有EXCEL4宏函数,都不能躲过密码,不信试试看:
Sub Macro1()
Dim p$, f$, m&, s$, a$, rng As Range, arr(1 To 3, 1 To 17)
Set rng = [A2:Q4]
p = ThisWorkbook.Path & "\数据\"
f = Dir(p & "*.xls")
s = "数据表"
Application.ScreenUpdating = False
ActiveSheet.UsedRange.ClearContents
m = 2
Do While f <> ""
If f <> ThisWorkbook.Name Then
Cells(m, 1) = Split(f, ".")(0)
For i = 1 To 3
For j = 1 To 17
a = rng(i, j).Address(0, 0)
arr(i, j) = getvalue(p, f, s, a)
Next
Next
Cells(m, 2).Resize(3, 17) = arr
m = m + 3
End If
f = Dir
Loop
Application.ScreenUpdating = True
End Sub
Private Function getvalue(pa As String, File As String, SHEET As String, REF As String)
Dim arg As String
arg = "'" & pa & "[" & File & "]" & SHEET & "'!" & Range(REF).Range("A1").Address(, , xlR1C1)
getvalue = ExecuteExcel4Macro(arg)
End Function |
|