0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

エクセルで重複している値を持っている行を削除する

0
Posted at

エクセルの表である一列内にある値が重複していて、その重複している値を持っている行を削除するマクロです。
備忘録で投稿しておきます。

Sub Macro2()

Dim a As String
Dim i As Integer
Dim t As Integer

ActiveCell.Select
a = ActiveCell.Value
ActiveCell.Offset(1, 0).Select

Application.ScreenUpdating = False

For i = 1 To 4141
Debug.Print "a:" & a & "| count:" & i

If a = ActiveCell.Value Then
    Selection.EntireRow.Delete
    
    For t = 1 To 10000 '一応処理のために時間を置いておく
    Next t

    Else
    ActiveCell.Offset(1, 0).Select
    a = ActiveCell.Value
End If

Next

End Sub
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?