- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
8#
發表於 2016-10-7 06:22
| 只看該作者
回復 7# swatt - Option Explicit
- Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
- Dim Rng As Range
- Set Rng = Range("H2:I2")
- If Not Intersect(Target, Rng) Is Nothing Then
- '*******************************************************************
- 'Intersect 方法 傳回 Range 物件,此物件代表兩個或多個範圍重疊的矩形範圍
- '*******************************************************************
- 'If Target = [h2] Or Target = [i2] Then
- If (Not IsNumeric(Target.Value)) Or IsEmpty(Target.Value) Then
- MsgBox "Must be numeric value!"
- Application.EnableEvents = False
- Target.Value = "" 'this will trigger Target again
- [j2].Value = "" 'clear the cell of yield
- Application.EnableEvents = True
- 'Exit Sub
- End If
- End If
- End Sub
複製代碼 |
|