If E <> Application.Evaluate(M) Then MsgBox E.Address(0, 0) & "= " & E & " 填入號碼與預設不同"
End If
Next
End Sub
複製代碼
作者: 准提部林 時間: 2015-11-29 13:33
本帖最後由 准提部林 於 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作者: 准提部林 時間: 2015-11-29 13:36
本帖最後由 准提部林 於 2015-11-29 17:41 編輯
If E <> N Then
MsgBox "輸入內容錯誤!將自動〔還原〕∼∼ "
Application.EnableEvents = False Application.Undo '執行還原指令 Application.EnableEvents = True
End If作者: RCRG 時間: 2015-11-29 16:36
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
If E <> N And E(1, 2) <> "" Then
MsgBox "輸入內容錯誤!將自動修正∼∼ "
Application.EnableEvents = False
E = N
Application.EnableEvents = True
End If
End If
Next
End Sub作者: RCRG 時間: 2015-11-29 17:41
'工作表A 模組
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim E As Range, M As String
'Intersect 方法 傳回 Range 物件,此物件代表兩個或多個範圍重疊的矩形範圍。
For Each E In Target
If Not Application.Intersect(E, [B3:B79]) Is Nothing Then
'IF(C3="""","""",3^(1-COUNT(MATCH(C3,AA$3:AA$500,))))"
M = "IF(" & E(1, 2).Address & "="""","""",3^(1-COUNT(MATCH(" & E(1, 2).Address & ",AA$3:AA$500,))))"
If E <> Application.Evaluate(M) And E(1, 2) <> "" Then MsgBox E.Address(0, 0) & "= " & E & " 填入號碼與預設不同"
End If
Next
End Sub