Rabu, 22 Agustus 2012

Re: [ExcelVBA] Re: specfic character pick

 

You SAY "specific words":

That itself has "specific meaning".

In a previous posting you mentioned that you wanted an EXACT MATCH for the word.
So, the "lay" in "layout" is NOT a match.

A WORD can be at the beginning, followed by a space or perhaps a comma.
at the END, preceeded by a space,
or within the string, with a space beginning and following the word (or perhaps
a comma following)
The instr() function will look for  a specific character string.
So you may be able to modify something like:

Sub srch()
    Dim R, FindFlag
    Dim tString
    Dim txt
    tString = "water"
    For R = 1 To 20
        FindFlag = False
        If (Cells(R, "A").Value <> "") Then
            txt = UCase(Cells(R, "A").Value)
            If ((Left(txt, Len(tString) + 1) = UCase(tString) & " ") _
             Or (Right(txt, Len(tString) + 1) = " " & UCase(tString)) _
             Or (InStr(1, txt, " " & UCase(tString) & " ") > 0) _
             Or (InStr(1, txt, " " & UCase(tString) & ",") > 0) _
             ) Then
                    MsgBox "row: " & R & " Found: " & tString
            End If
           
        End If
    Next R
End Sub

Paul
-----------------------------------------
"Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can." - John Wesley
-----------------------------------------

________________________________
From: Tayyab <sheikhtayyab@yahoo.com>
To: "ExcelVBA@yahoogroups.com" <ExcelVBA@yahoogroups.com>
Sent: Wed, August 22, 2012 7:52:28 AM
Subject: Re: [ExcelVBA] Re: specfic character pick

 
my task is to get specific words for the sentence, if they existed like tay, lay
function tay or lay.

Function FindText(txt) As String
 
>>
>> If (InStr(txt, "tay") > 0) Then
>> FindText = "tay"
>> ElseIf (InStr(txt, "lay") > 0) Then
>> FindText = "lay"
>> ElseIf (InStr(txt, "www") > 0) Then
>> FindText = "www"
>> Else
>>     FindText = "Nothing"
>> End If
>>
>> End Function

________________________________
From: "1z@compuserve.com" <1z@compuserve.com>
To: ExcelVBA@yahoogroups.com
Sent: Tuesday, August 21, 2012 9:06 PM
Subject: Re: [ExcelVBA] Re: specfic character pick

 

Good question!!!

Lisa

Sent: Tue, Aug 21, 2012 5:15 pm
Subject: Re: [ExcelVBA] Re: specfic character pick

What is the end use of this code? What are you writing it for?

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar