- 帖子
- 835
- 主題
- 6
- 精華
- 0
- 積分
- 915
- 點名
- 0
- 作業系統
- Win 10,7
- 軟體版本
- 2019,2013,2003
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2010-5-3
- 最後登錄
- 2024-11-14
|
2#
發表於 2014-11-22 01:36
| 只看該作者
把多筆excel名稱為數字(如下圖)且不連續的檔案整合到同一個excel檔
(多筆excel檔案內容格式都一樣,只有數 ...
smart00361 發表於 2014-11-20 16:45  - Sub nn()
- Dim lRow&
- Dim sFlNm$
- Dim shTar As Worksheet
-
- Set shTar = ThisWorkbook.Sheets(1)
- With shTar
- .Cells.Clear
- .[A1].Select
- End With
- sFlNm = Dir("*.xls")
- lRow = 2
- Do While sFlNm <> ""
- With Workbooks.Open(sFlNm, , 1)
- shTar.Activate
- With .Sheets(1).Cells(lRow, 1)
- shTar.Cells(lRow, 1) = Left(sFlNm, Len(sFlNm) - 4)
- shTar.Cells(lRow, 2) = Application.Sum(.Parent.Range("B106:B287")) / 182
- .Range("B87:B107").Copy
- shTar.Cells(lRow, 3).PasteSpecial Transpose:=True
- End With
- .Close False
- End With
- sFlNm = Dir
- lRow = lRow + 1
- Loop
- End Sub
複製代碼 |
|