- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
2#
發表於 2012-4-21 06:16
| 只看該作者
本帖最後由 GBKEE 於 2012-4-21 06:33 編輯
回復 1# luke
將所有的核取方塊 指定巨集 為此程序- Option Explicit
- Sub Ex()
- Dim D As Object, 區域 As String, E, Check As Object
- Set D = CreateObject("Scripting.Dictionary")
- With sheet1
- Set Check = ActiveSheet.Shapes(Application.Caller).OLEFormat.Object '選取的 核取方塊
- 區域 = Check.Caption '核取方塊的標題文字
- For Each E In .Range("A9").CurrentRegion.Columns(1).Cells
- If E = 區域 Then D(E.Cells(1, 2) & E.Cells(1, 3)) = E.Cells(1, 4)
- Next
- End With
- With sheet2
- For Each E In .Range("A1").CurrentRegion.Columns(1).Cells
- If Check.Value=1 Then
- If D(E & E.Cells(1, 2)) <> "" Then E.Cells(1, 4) = D(E & E.Cells(1, 2)) + E.Cells(1, 3)
- Else
- If D(E & E.Cells(1, 2)) <> "" Then E.Cells(1, 4) = E.Cells(1, 3)
- End If
- Next
- End With
- End Sub
複製代碼 |
|