Login dark
title: Excel查找重复值-VBA查找
author: Love02xp
date: 2023-04-02 11:04:17
category: [编程代码]
tags: [VBA,代码,学习]

需要的查找的A列,在重复值的C列显示重复2个字

Sub 同一列重复()
Dim Arr, i&, Myr&, d
Set d = CreateObject("Scripting.Dictionary")
Sheet1.Activate
[c:c].Clear
Myr = [a1000000].End(xlUp).Row
Arr = Range("a1:A" & Myr)
For i = 2 To UBound(Arr)
    If Not d.exists(Arr(i, 1)) Then
        d(Arr(i, 1)) = ""
    Else
        Cells(i, 3) = “重复”
    End If
Next
End Sub