0
當我按下「刪除」或「退格鍵」時沒有任何反應。
它應該清潔細胞。Application.OnKey事件沒有執行
Private Sub Worksheet_Change(ByVal Target As Range)
Dim TestCell
Dim RE As Object
Dim REMatches As Object
Dim Cell1_1 As String
Dim Today As String
ThisRow = Target.Row
Application.OnKey "{DELETE}", "CleanCell1_1"
Application.OnKey "{BACKSPACE}", "CleanCell1_1"
If Target.Column = 10 Then
Set RE = CreateObject("vbscript.regexp")
With RE
.MultiLine = False
.Global = False
.IgnoreCase = True
.Pattern = "[G,g,Y,y,R,r]"
End With
For Each TestCell In Target.Cells
Set REMatches = RE.Execute(TestCell.Value)
If REMatches.Count > 0 Then
Today = Now()
Cell1_1 = Sheets("Input").Cells(1, 1).Value
Range("L" & ThisRow) = Cell1_1 + ": " + Format(Today, "ddmmmyy")
'MsgBox "Invalid:" & TestCell.Address & "-" & TestCell.Value
'TestCell.Value = ""
Else
MsgBox "Error"
End If
Next
End If
End Sub
那麼,你的問題是什麼? – 2015-03-13 14:15:40
澄清問題和標題。 – 2015-03-13 17:36:32