相同单元格自动变色提醒
2024-04-28 18:56:35

相同单元格自动变色提醒

Private Sub Worksheet_SelectionChange(ByVal T As Range)

Dim Rg As Range,相同醒 SumRg As Range

If T.Value = "" Then Exit Sub

Set Rg = Range("A1").CurrentRegion.Find(T, Lookat:=xlWhole)

MyAddress = Rg.Address

Do

Set Rg = Range("A1").CurrentRegion.FindNext(Rg)

k = k + 1

If k = 1 Then

Set SumRg = Rg

Else

Set SumRg = Application.Union(SumRg, Rg)

End If

Loop While Rg.Address <> MyAddress

Application.EnableEvents = False

SumRg.Select

Range("A1").CurrentRegion.Interior.ColorIndex = xlNone

SumRg.Interior.ColorIndex = 6

Application.EnableEvents = True

End Sub

(作者:汽车电瓶)