EXCEL VBA 重複行削除
EXCEL VBA 重複行削除
開始行 = 2
終了チェックカラム = “B”
比較対象カラム = “B”
For ii = 開始行 To 5000
DoEvents
If ActiveSheet.Range(終了チェックカラム & CStr(ii)).Value = “” Then
Exit For
End If
For jj = ii + 1 To 5000
DoEvents
If ActiveSheet.Range(終了チェックカラム & CStr(jj)).Value = “” Then
Exit For
End If
If ActiveSheet.Range(比較対象カラム & CStr(ii)).Value = ActiveSheet.Range(比較対象カラム & CStr(jj)).Value Then
If ActiveSheet.Range(比較対象カラム & CStr(ii)).Value = “” Then
GoTo SKIP0
End If
Debug.Print “①[” & ii & “]” & ActiveSheet.Range(比較対象カラム & CStr(ii)).Value
Debug.Print “②[” & jj & “]” & ActiveSheet.Range(比較対象カラム & CStr(jj)).Value
Debug.Print “”
ActiveSheet.Rows(jj).Select
ActiveSheet.Rows(jj).Delete Shift:=xlUp
jj = jj – 1
End If
SKIP0:
Next jj
Next ii
End Sub