|
おはようございます。
既に正解投稿がありますので
参考程度に試してみて下さい。
'===================================================
Sub main()
Dim rng As Range
Dim radd As String
Dim ans As Variant
Set rng = Range("A1", Range("A65536").End(xlUp))
If rng.Count > 1 Then
radd = rng.Address
ans = Join(Filter(Evaluate("=transpose(IF(COUNTIF(" & _
radd & "," & radd & ")=1,ROW(" & _
radd & ")&"":""&ROW(" & radd & "),""NG""))") _
, "NG", False), ",")
'仮にデータがセルA1:A8に入っていた場合は↓の式を評価します
' =Transpose(IF(COUNTIF($A$1:$A$8,$A$1:$A$8)=1, _
ROW($A$1:$A$8)&":"&ROW($A$1:$A$8), _
"NG"))
Else
ans = rng.Address
End If
If ans <> "" Then
Range(ans).Delete
End If
End Sub
|
|