-1

列 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

しかし、私は自分のエラーを見つけることができません。

4

1 に答える 1

0

クイックスキャンだけ。
このコード:

If x.Value = Sheets("Sheet1").Cells(iCtr, 1).Value Then

YyourとAnotの値を比較しますC
代わりにこのようにする必要があります。

If x.Value = Sheets("Sheet1").Cells(iCtr, 3).Value Then
于 2013-11-13T09:46:46.130 に答える