- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 142
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2026-7-16
                
|
本帖最後由 Hsieh 於 2013-2-26 14:18 編輯
回復 3# lifedidi
Sheet2模組- Private Sub CommandButton1_Click()
- FormA.Show 0
- End Sub
複製代碼 FormA模組- Private Sub CommandButton1_Click()
- FormB.Show 0
- End Sub
- Private Sub UserForm_Initialize()
- Set d = CreateObject("Scripting.Dictionary")
- With Sheet1
- For Each a In .Range(.[A2], .[A1].End(xlDown))
- d(a.Value) = ""
- Next
- End With
- ComboBox1.List = d.keys
- End Sub
複製代碼 FormB模組- Private Sub CommandButton1_Click()
- FormC.Show 0
- FormC.計算 1
- End Sub
- Private Sub CommandButton2_Click()
- FormC.Show 0
- FormC.計算 2
- End Sub
複製代碼 FormC模組- Sub 計算(work As Integer)
- Dim Ar()
- With Sheet1
- For Each a In .Range(.[A2], .[A1].End(xlDown))
- If a.Value = FormA.ComboBox1.Value Then
- ReDim Preserve Ar(s)
- Ar(s) = a.Offset(, 1).Value
- s = s + 1
- End If
- Next
- End With
- If work = 1 Then ListBox1.AddItem Format(Application.Sum(Ar), "hh:mm:ss")
- If work = 2 Then ListBox1.AddItem Format(Application.Average(Ar), "hh:mm:ss")
- End Sub
複製代碼
Form Test.zip (12.55 KB)
|
|