Problem: Find all occurrences of "green tree" AND "red fish" OR "blue ink" AND "people will help you".
These are enough examples to set the issue. The standard FIND method works great - for only ONE item word or phrase. - what if a user wants to FIND several unique words or phrases in one search? Can that be done? The following works great for ONE value or phrase only:
As mentioned above, x = Me.TextBox6.Value 'enter any word or phrase finds only one word or phrase.
if Excel would accept something like Textbox6 = x = green tree #AND# red fish #OR# blue ink #AND# people will help you
and satisfy every one of these requests, that would solve the problem.
Can anyone help? I really appreciate it.
Thanks, cr
These are enough examples to set the issue. The standard FIND method works great - for only ONE item word or phrase. - what if a user wants to FIND several unique words or phrases in one search? Can that be done? The following works great for ONE value or phrase only:
Code:
Private Sub cmdFIND_Click()
Sheets("RESULT").UsedRange.ClearContents
Dim lastrow As Integer
Dim x As String
Dim c As Range
Dim rw As Long
Dim firstAddress As Variant
Dim Rowno As Variant
x = Me.TextBox6.Value 'enter any word or phrase.
With Worksheets("Sheet2").Range("C1:C31103")
Set c = .FIND(x, LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False, SearchFormat:=False)
If Not c Is Nothing Then
rw = 1
firstAddress = c.Address
Do
Worksheets("Sheet2").Select
c.Select
Range(Cells(c.Row, 2), Cells(c.Row, 7)).Copy Destination:=Sheets("RESULT").Range("B" & rw)
' Range(Cells(c.Row, 2), Cells(c.Row, 7)).Copy Destination:=Sheets("RESULTA").Range("B" & rw) 'just makes an extra copy to another sheet
rw = rw + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
lastrow = Sheets("RESULT").Range("B" & Rows.count).End(xlUp).Row
If lastrow = 1 Then
Range(Cells(c.Row + 7, 2), Cells(c.Row, 7)).Copy Destination:=Sheets("RESULT").Range("B" & rw)
' Range(Cells(c.Row, 2), Cells(c.Row, 7)).Copy Destination:=Sheets("RESULTA").Range("B" & rw)
Else
End If
End If
Sheets("Sheet3").Select
End With
Rowno = Sheets("RESULT").Range("B2").End(xlDown).Row
'RownoA = Sheets("RESULTA").Range("B2").End(xlDown).Row
Sheets("RESULT").Range("H1").Value = Rowno
Sheets("RESULT").Range("I1").Value = x
'Sheets("RESULTA").Range("H1").Value = Rowno
'Sheets("RESULTA").Range("I1").Value = x
ListBox1.ListIndex = 0
Me.TextBox17.Value = lastrow
Me.TextBox16.Value = firstrow
End Sub
if Excel would accept something like Textbox6 = x = green tree #AND# red fish #OR# blue ink #AND# people will help you
and satisfy every one of these requests, that would solve the problem.
Can anyone help? I really appreciate it.
Thanks, cr