- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
5#
發表於 2010-8-3 17:41
| 只看該作者
本帖最後由 GBKEE 於 2010-8-3 18:51 編輯
復 4# myleoyes
Leov18-2.xls 中只有夢想 Leov18-1.xls 中有夢想,99,100裡面都是公式
給你的程式中 .SpecialCells(xlCellTypeFormulas) 就是公式的參數
應該是 如圖的需求 你沒有說清楚
- Sub 年度項目()
- Dim Y, C%, TILE$, Sh As Worksheet
- Sheets("首頁").Activate
- On Error GoTo Er:
- Ag:
- Y = Application.InputBox("輸入年度" & TILE, , 99)
- If Y = False Then Exit Sub
- If Y = "夢想" Then
- Set Sh = Sheets("夢想")
- Else
- Set Sh = Sheets(Y & "年度夢想")
- End If
- With Range("A4:E4")
- .Insert 'Shift:=xlDown
- .Cells(0, 1).NumberFormatLocal = "YYYY/MM/DD"
- .Cells(0, 1) = Y & "/1/1"
- .Cells(0, 2) = Sh.Name
- For I = 1 To Sh.Range("A:A").SpecialCells(xlCellTypeFormulas).Cells.Count
- .Cells(0, I + 2) = Sh.Range("A:A").SpecialCells(xlCellTypeFormulas).Areas(I)
- Next
- End With
- Exit Sub
- Er:
- TILE = Chr(10) & " *** 找不到 " & Y & "年度夢想 工作表 ***"
- Resume Ag
- End Sub
複製代碼 |
|