- 帖子
- 835
- 主題
- 6
- 精華
- 0
- 積分
- 915
- 點名
- 0
- 作業系統
- Win 10,7
- 軟體版本
- 2019,2013,2003
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2010-5-3
- 最後登錄
- 2024-11-14
|
2#
發表於 2011-7-5 23:22
| 只看該作者
- Sub nn()
- Dim iI%, iRowEnd%, iTarRow%
- Dim sGroup$
- Dim vMer
-
- Set vMer = Sheets("合併")
- iTarRow = 2
-
- For iI = 1 To Sheets.Count
- With Sheets(iI)
- If .Name <> vMer.Name Then
- sGroup = .Name
- iRowEnd = .Cells(Rows.Count, 1).End(xlUp).Row
- .Range(.Cells(2, 1), .Cells(iRowEnd, 2)).Copy
- With vMer
- .Paste Destination:=.Cells(iTarRow, 1)
- .Cells(iRowEnd + iTarRow - 2, 3) = sGroup
- .Range(.Cells(iTarRow, 3), .Cells(iRowEnd + iTarRow - 2, 3)).FillUp
- End With
- iTarRow = iRowEnd + iTarRow - 1
- End If
- End With
- Next iI
- End Sub
複製代碼 |
|