你是想在输入的时候提示吗?例如A列 代码如下 Private Sub Worksheet_Change(ByVal Target As Range) Dim r&, i& If Target.Column = 1 And Target.Count = 1 Then r = Target.Row i = Application.CountIf(Range("A1:A" & r), Target.Value) If i > 1 Then MsgBox Target.Value & "重复了" End If End If
假如A列 for i=1 to usedrange.rows.count for j=i +1 to usedrange.rows.count if cells(i,1)=cells(j,1) then msgbox "A列第" & i & "行值:" & cells(i,1) & “和第" & j & "行值重复。" exit for end if next j next i