列 C のリストをセル Y1001 から始まるリストと比較しようとしていますが、重複が存在する場合、列 C から重複の行全体を削除したいと考えています。
ただし、私のコードはこの結果を生成していません! 私のエラーはどこですか?
ありがとう!
Sub Button3_Click()
'run comparison'
'Turn off screen updating to speed up macro'
Application.ScreenUpdating = False
Dim iListCount As Long
Dim x As Variant
Dim iCtr As Long
' Get count of records to search through (list that will be deleted)'
iListCount = Sheets("Sheet1").Cells(Rows.Count, "C").End(xlUp).Row
' Loop through the "master" list'
For Each x In Sheets("Sheet1").Range("Y1001:Y" & Sheets("Sheet1").Cells(Rows.Count, "C").End(xlUp).Row)
' Loop through all records in the second list.
For iCtr = iListCount To 1 Step -1
' Do comparison of next record'
If x.Value = Sheets("Sheet1").Cells(iCtr, 1).Value Then
' If match is true then delete row.
Sheets("Sheet1").Cells(iCtr, 1).EntireRow.Delete
End If
Next iCtr
Next
Application.ScreenUpdating = True
End Sub
追加情報:
「実行時エラー 424: オブジェクトが必要です」というメッセージが表示されます
デバッグを実行すると、エラー行は次のようになります。
If x.Value = Sheets("Sheet1").Cells(iCtr, 1).Value Then
しかし、私は自分のエラーを見つけることができません。