標題:
如何使用陣列到不同sheet抓取資料
[打印本頁]
作者:
yueh0720
時間:
2013-12-4 11:56
標題:
如何使用陣列到不同sheet抓取資料
各位大大,
請問該如何使用陣列到不同sheet抓取資料
檔案如附件
[attach]16956[/attach]
作者:
ML089
時間:
2013-12-4 17:52
回復
1#
yueh0720
是這樣嗎?
Private Sub Update_Click()
Dim y&, xR As Range, uP$, uF$
xRange = Array("$C$5", "$D$10", "$J$21", "$J$26")
uP = ThisWorkbook.Path & "\"
Application.ScreenUpdating = False
For Each xR In Range([A2], [A65536].End(3))
If Dir(uP & xR) = "" Then GoTo 101
uF = "'" & uP & "[" & xR & "]Sheet1'!"
j = 2
For Each xC In xRange
xR(1, j) = "=" & uF & xC
j = j + 1
Next
101:
Next
End Sub
複製代碼
作者:
yueh0720
時間:
2013-12-5 15:14
ML089 大,
沒辦法~分頁無法複製
作者:
ML089
時間:
2013-12-5 21:06
回復
3#
yueh0720
Private Sub Update_Click()
Dim y&, xR As Range, uP$, uF$
xRange = Array("Sheet1'!C5", "Sheet1'!D10", "Sheet1'!J21", "Sheet1'!J26", _
"第三頁'!C5", "第三頁'!D10", "第三頁'!J21", "第三頁'!J26", _
"第七頁'!C5", "第七頁'!D10", "第七頁'!J21", "第七頁'!J26")
uP = ThisWorkbook.Path & "\"
Application.ScreenUpdating = False
For Each xR In Range([A2], [A65536].End(3))
If Dir(uP & xR) = "" Then GoTo 101
uF = "'" & uP & "[" & xR & "]"
j = 2
For Each xC In xRange
xR(1, j) = "=" & uF & xC
j = j + 1
Next
101:
Next
End Sub
複製代碼
作者:
ML089
時間:
2013-12-5 21:09
回復
3#
yueh0720
如果你對那層樓有意見時,請按該層樓下方的回覆,這樣系統才會通知。
作者:
Hsieh
時間:
2013-12-6 08:45
回復
1#
yueh0720
Private Sub Update_Click()
Dim y&, xR As Range, uP$, uF$, Ar(), Sh As Worksheet
uP = ThisWorkbook.Path & "\"
Application.ScreenUpdating = False
With Sheet1
For Each xR In .Range(.[A2], .[A65536].End(3)).SpecialCells(xlCellTypeConstants)
If Dir(uP & xR) = "" Then GoTo 101
With Workbooks.Open(uP & xR)
For Each Sh In .Sheets
With Sh
ReDim Preserve Ar(s)
Ar(s) = Array(.[C5].Value, .[D10].Value, .[J21].Value, .[J26].Value)
s = s + 1
End With
Next
.Close 0
End With
xR.Offset(, 1).Resize(s, 4) = Application.Transpose(Application.Transpose(Ar))
Erase Ar: s = 0
101: Next
End With
End Sub
複製代碼
作者:
yueh0720
時間:
2013-12-24 17:20
回復
5#
ML089
了解,謝謝告知
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)