- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
回復 11# yeh6712
詳看 10# 的圖示
重算事件 ,Change 事件 需二擇一執行,- Option Explicit
- Private Sub Worksheet_Calculate()
- Dim i As Integer, M As Variant, S As Integer, Rng As Range
- i = 2
- Do While Cells(i, "F").Formula <> "" '有公式
- S = 0 '不是男女
- If Cells(i, "C") = "男" Then
- S = 1 'A欄
- ElseIf Cells(i, "C") = "女" Then
- S = 4 'D欄
- End If
- If S > 0 And Cells(i, "F") > 0 Then
- If Cells(i, "F") < Sheets("仰臥起坐").Columns(S).Cells(2, 1) Then
- M = Application.Match(Cells(i, "F"), Sheets("仰臥起坐").Columns(S), 0)
- ElseIf Cells(i, "F") >= Sheets("仰臥起坐").Columns(S).Cells(2, 1) Then
- M = 2 '100分
- End If
- If IsNumeric(M) Then Cells(i, "G") = Sheets("仰臥起坐").Columns(S).Cells(M, 2)
- 'Application.Match 工作表的函數:沒有找到時傳回 錯誤值
- Else
- Cells(i, "G") = ""
- End If
- i = i + 1
- Loop
- End Sub
複製代碼 |
|