你需要把你的數(shù)據(jù)含標題粘貼到A列運行一下函數(shù)就ok
Sub 刪除重復值() Range("A1:A" & Range("A65536").End(xlUp).Row).Copy Range("B1") '復制A列數(shù)據(jù)到B列 ActiveSheet.Range("B:B").RemoveDuplicates Columns:=1, Header:=xlYes '刪除B列重復值 Dim rng As Range '聲明rng為單元格變量 For Each rng In Range("B2:B" & Range("B65536").End(xlUp).Row) rng.Offset(0, 1) = Application.WorksheetFunction.CountIf(Range("A:A"), rng) Range("C1") = "重復情況" Next ' 用for each函數(shù)遍歷B列有數(shù)據(jù)的單元格,,用offset偏離函數(shù)在C列求重復次數(shù) End Sub
|