- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
|
6#
發表於 2011-5-27 14:47
| 只看該作者
回復 5# tomking
需求.xls,OS124.xls,OS123.xls 等都開啟的狀態下的程式碼- Option Explicit
- Sub Ex()
- Dim MyBook As Workbook, B As Workbook, R As Range, i As Long
- Set MyBook = Workbooks("需求.XLS")
- For Each B In Workbooks '
- If B.Name <> MyBook.Name Then
- With B.Sheets(1)
- For i = 4 To .Cells(Rows.Count, "A").End(xlUp).Row
- Set R = MyBook.Sheets("LIST").Cells(Rows.Count, "A").End(xlUp).Offset(1)
- R.Resize(, 4) = Array(.[C1], .[E1], .[I2], .[A2])
- R.Offset(, 4).Resize(, 11) = .Range(.Cells(i, "A"), .Cells(i, "K")).Value
- Next
- End With
- End If
- Next
- End Sub
複製代碼 |
|