- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
回復 7# Andy2483
3.再請教前輩 網查 Const 是常數的意思,有用它跟沒用都可以執行
3.1.在程式的設計上 Const 有甚麼時候是非用不可呢? 請您再指導
Const L = 20: Const T = 20
Const 指定變數固定的內容 最好加註說明 ,當程式寫的龐大時如修改變數內容,只需修改這裡.
n7822123 , ikboy 的回覆多加練習,不懂可多看說明,再提問會進步的
下面的程式參考看看- Option Explicit
- '365 之前版本只有 Comment 物件 為[註解]
- '365 版本中 Comment 物件 為[附註]
- '365 版本中 新增CommentThreaded 物件 為[註解]
- Sub Ex註解()
- Dim Msg As String
- With ActiveSheet
- If .Comments.Count > 0 Then Msg = "[附註] 有" & .Comments.Count & "個 " & 註解副程式(.Comments)
- If Application.Version >= 16 Then '版本365以上
- If Msg <> "" Then Msg = Msg & vbLf & vbLf
- If .CommentsThreaded.Count >= 0 Then Msg = Msg & "[註解] 有" & .CommentsThreaded.Count & "個 " & 註解副程式(.CommentsThreaded)
- End If
- If Msg = "" Then Msg = .Name & " 沒有任何 註解...."
- MsgBox Msg
- End With
- End Sub
- Function 註解副程式(comm As Object) As String
- Dim e As Object, 註解 As String
- For Each e In comm
- If TypeName(e) = "CommentThreaded" Then '版本365以上
- 註解 = 註解 & IIf(註解 <> "", vbLf, "") & e.Parent.Cells.Address & " " & e.Text
- Else ' 版本365以下
- 註解 = 註解 & IIf(註解 <> "", vbLf, "") & e.Shape.TopLeftCell.Address & " " & e.Text
- End If
- Next
- 註解副程式 = vbLf & 註解
- End Function
複製代碼 |
|