0

I have a question for anyone; I am writing a program that will create a record in excel; I have a working program. I am having difficulties using the .findNext. Below is what I have so far (it would find the first word for me), I will like for it to find the next word if the user searches for the same word next time.

word = frmSearch.txtEnterDate.Text
If frmSearch.cboShiftSelect.Text = "1" Then
Sheets("Current").Select
Range("A1:C65536").Find(What:=word, LookAt:=xlWhole, LookIn:=xlValues, SearchOrder:=xlByColumns).Activate
'Range("A1:C65536").FindNext(After:=word).Activate
2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by williamrojas78
0

Hi

i assume this is vba, right?
i don't see the definition and/or assignment of the variable "word"
try this

dim word as string
word = "xxx"
Cells.Find(What:=word, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate


Cells.FindNext(After:=ActiveCell).Activate

the first line will find the word "xxx":
the second one will find the next one.

so make a global counter increase it everytime the user runs the macro, and then search as many times as the counter.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.