電子書籍の厳選無料作品が豊富!

以下、WindFaller様にご教示いただきました回答より。

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long, j As Long
Dim Rng As Range
 If Target.Count <> 1 Then Exit Sub
 If Target.Row > 501 Then Exit Sub
 If Target.Column > 702 Then Exit Sub '702=ZZ
  i = Int((Target.Row - 1) / 5) * 5 + 1
  j = i + 4
  Set Rng = Range(Cells(i, 1), Cells(j, 702))
 Application.EnableEvents = False
 If Application.WorksheetFunction.CountIf(Rng, Target.Value) > 1 Then
  MsgBox "重複した値です。"
  Target.ClearContents
  End If
  Set Rng = Nothing
 Application.EnableEvents = True
End Sub

希望する動作:このプログラムを改良し、特定の文字列(該当単語が20個程あります)が入力された場合は、重複チェックプログラムが動作しないようにしたいです。

ご教示のほど、よろしくお願いいたします。

A 回答 (1件)

------------------------------------------------------------


If Target.Count <> 1 Then Exit Sub
If Target.Row > 501 Then Exit Sub
If Target.Column > 702 Then Exit Sub '702=ZZ
------------------------------------------------------------
以上のところどこでも良いので次のようなものを入れればよいだけだと思います。
------------------------------------------------------------
If Target.Value = "特定の文字①" Then Exit Sub

If Target.Value = "特定の文字⑳" Then Exit Sub
------------------------------------------------------------
    • good
    • 0
この回答へのお礼

動作確認出来ました。
ご教示ありがとうございます。大変助かりました。

お礼日時:2016/09/15 17:19

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!