私はvbaを使用しており、「Do Not Call」という名前の2つのシートがあり、列Aに約800,000行のデータがあります。このデータを使用して、「Sheet1」という名前の2番目のシートの列Iを確認したいと思います。一致が見つかった場合は、「Sheet1」の行全体を削除してください。ここで同様の質問から見つけたコードを調整しました: Excel formula to Cross reference 2 sheets, remove duplicates from one sheet and run it but何も起こりません。エラーは発生していませんが、機能していません。
ここに私が現在試しているコードがあり、なぜそれが機能しないのか分かりません
Option Explicit
Sub CleanDupes()
Dim wsA As Worksheet
Dim wsB As Worksheet
Dim keyColA As String
Dim keyColB As String
Dim rngA As Range
Dim rngB As Range
Dim intRowCounterA As Integer
Dim intRowCounterB As Integer
Dim strValueA As String
keyColA = "A"
keyColB = "I"
intRowCounterA = 1
intRowCounterB = 1
Set wsA = Worksheets("Do Not Call")
Set wsB = Worksheets("Sheet1")
Dim dict As Object
Set dict = CreateObject("Scripting.Dictionary")
Do While Not IsEmpty(wsA.Range(keyColA & intRowCounterA).Value)
Set rngA = wsA.Range(keyColA & intRowCounterA)
strValueA = rngA.Value
If Not dict.Exists(strValueA) Then
dict.Add strValueA, 1
End If
intRowCounterA = intRowCounterA + 1
Loop
intRowCounterB = 1
Do While Not IsEmpty(wsB.Range(keyColB & intRowCounterB).Value)
Set rngB = wsB.Range(keyColB & intRowCounterB)
If dict.Exists(rngB.Value) Then
wsB.Rows(intRowCounterB).delete
intRowCounterB = intRowCounterB - 1
End If
intRowCounterB = intRowCounterB + 1
Loop
End Sub
上記のコードがコードタグにない場合は申し訳ありません。コードをオンラインで投稿するのはこれが初めてで、正しく投稿したかどうかわかりません。