简体   繁体   中英

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

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

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

i have included sample workbook for anyone kind enough

thank you all

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM