返回列表 上一主題 發帖

[發問] 當B欄號碼與預設規則不同時,如何彈出視窗提醒?

本帖最後由 准提部林 於 2015-11-29 16:58 編輯

Private Sub Worksheet_Change(ByVal Target As Range)
Dim E As Range, M, N
If [B1] = 111 Then Exit Sub '作動〔關閉〕 
For Each E In Target
  If Not Application.Intersect(E, [B3:B79]) Is Nothing Then
   M = Application.Match(E(1, 2), [AA3:AA500], 0)
   If IsError(M) Then N = 3 Else N = 1
   If E(1, 2) = "" Then N = ""
   If E <> N Then
    MsgBox "輸入內容錯誤!將自動修正∼∼ "
    Application.EnableEvents = False
    E = N
    Application.EnableEvents = True
   End If
  End If
Next
End Sub

TOP

本帖最後由 准提部林 於 2015-11-29 17:41 編輯

   If E <> N Then
    MsgBox "輸入內容錯誤!將自動〔還原〕∼∼ "
    Application.EnableEvents = False
    Application.Undo '執行還原指令
    Application.EnableEvents = True
   End If

TOP

本帖最後由 准提部林 於 2015-11-29 17:03 編輯

回復 6# RCRG


If [B1] = 111 Then Exit Sub 
B1輸入111,不執行

C欄空格,不理會:
'If E(1, 2) = "" Then N = "" 刪去
If E <> N And E(1, 2) <> "" Then 加入判斷

TOP

        靜思自在 : 世上有兩件事不能等:一、孝順 二、行善。
返回列表 上一主題