相同单元格自动变色提醒

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

发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章