java 多个关键字检索_查找多个关键字并突出显示该行

如果您不提供代码或屏幕截图,很难回答 .

Option Explicit

Sub ColourMatchingCells()

With Thism Tab2range as range

'Replace Sheet2 below with whatever Tab 2 is named -- and A1:A50 with actual range address.'

Set Tab2range = .worksheets("Sheet2).range("A1:A50")

Dim cell as range

' Again, replace Sheet1 name and range address on next line with actual values'

With .worksheets("Sheet1").range("A1:K1000")

Dim AddressOfFirstMatch as string

Dim CellFound as range

Dim MatchAddress as string

For each cell in Tab2range

' Case insensitive search and which tries to find the whole value. You did not mention what type of data you're searching for e.g. strings, numbers, dates, etc. -- or what type of search you want. '

Set CellFound = .cells.find(what:=cell.value2,lookin:=xlvalues,lookat:=xlwhole,searchdirection:=xlnext,Matchcase:=False)

If not (CellFound is nothing) then

AddressOfFirstMatch = CellFound.address

CellFound.interior.color = vbblue 'just an example'

Do

Set CellFound = .findnext(CellFound)

CellFound.interior.color = vbblue

MatchAddress = CellFound.address

Doevents ' If you experience infinite loop or bad logic, spam/hold Escape or Break key on keyboard'

Loop until strcomp(AddressOfFirstMatch,MatchAddress, vbbinarycompare) = 0

End if

Next cell

End with

End with

End Sub

它有用吗?它能做你想要的吗?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值