返回列表 上一主題 發帖

[發問] Workbook_SheetChange 疑問

回復 7# swatt
  1. Option Explicit
  2. Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
  3. Dim Rng As Range
  4.     Set Rng = Range("H2:I2")
  5.     If Not Intersect(Target, Rng) Is Nothing Then
  6.     '*******************************************************************
  7.     'Intersect 方法   傳回 Range 物件,此物件代表兩個或多個範圍重疊的矩形範圍
  8.     '*******************************************************************
  9.     'If Target = [h2] Or Target = [i2] Then
  10.         If (Not IsNumeric(Target.Value)) Or IsEmpty(Target.Value) Then
  11.             MsgBox "Must be numeric value!"
  12.             Application.EnableEvents = False
  13.             Target.Value = ""  'this will trigger Target again
  14.             [j2].Value = ""    'clear the cell of yield
  15.             Application.EnableEvents = True
  16.         'Exit Sub
  17.         End If
  18.     End If
  19. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

        靜思自在 : 人要自愛,才能愛普天下的人。
返回列表 上一主題