EXCEL VBA:使带有部分文本的第一个单元格与宏运行的活动单元格匹配,然后在列表中的下一个单元格与后续的宏运行活动单元格

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15293763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 19:54:43  来源:igfitidea点击:

EXCEL VBA: make first cell with partial text match activecell with macro run, then next cell down the list with subsequent macro runs activecell

excelvbasearchselectpartial

提问by kamelkid2

Sub AASearchForPartialText()
Dim SearchValue As String
SearchValue = Range("d2").Value
    Columns("D:D").Select
    Selection.Find(What:=SearchValue, After:=ActiveCell, LookIn:=xlValues, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate
End Sub

i am trying to simplify/make faster the excel search feature a bit by allowing the user to search through a long list of names (sometimes 2000) by typing in the partial string they want to find, and hitting the search button. the desired result is that it will cycle through the list of names, highlighting the next sequential cell that matches

我试图通过允许用户通过输入他们想要查找的部分字符串并点击搜索按钮来搜索一长串名称(有时是 2000 个)来稍微简化/加快 Excel 搜索功能。期望的结果是它会在名称列表中循环,突出显示匹配的下一个连续单元格

the best that i am doing is highlighting the range d:d. can anyone help me out please?

我正在做的最好的事情是突出范围 d:d。有人可以帮我吗?

i have included sample workbook for anyone kind enough

我已经为任何人提供了示例工作簿

thank you all

谢谢你们

https://www.dropbox.com/s/uahuzsu3a8qfv6z/searchpartial.xlsm

https://www.dropbox.com/s/uahuzsu3a8qfv6z/searchpartial.xlsm

回答by kamelkid2

i was actually able to figure this out one on my own with some help for other somewhat relevant code

我实际上能够在其他一些相关代码的帮助下自己解决这个问题

sorry to waste anybody's time

抱歉浪费任何人的时间

Sub newsearchrecord()
Dim SearchValue As String
SearchValue = "*" & Range("D2").Value & "*"
    Cells.Find(What:=SearchValue, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
    Cells.FindNext(After:=ActiveCell).Activate    
End Sub