Hi,
I just want to check if there is a same word exists in a cell, if there is, B1 should be tagged as "Y" else tagged as "N"
I have attached my file.
Thanks in advance gurus!
Hi,
I just want to check if there is a same word exists in a cell, if there is, B1 should be tagged as "Y" else tagged as "N"
I have attached my file.
Thanks in advance gurus!
One way would be to treat the contents of the cell as a string.
Loop through the string, one character at a time. Each time you come to a space, that signifies the end of a word. "Build" your words in this manner and store that word you just found in a one dimensional table.
After you've stored all of the words in your table, you simply loop through the table, searching it.
You check Word #1 against Word #2, Word #3, Word #4, etc., thru to the end. If you ever find a match, tag B1 as Yes and exit the loop. You're done.
Once you get thru to the end, if no match, then Word #1 doesn't equal anything.
And if so, now you have to check Word #2 against Word #3, Word #4, Word #5, etc., thru to the end. Again, if a match, tag as yes and exit the loop.
And so on.
Eventually you will have checked all words against each other.
There's probably more elegant ways of doing this but this is the first thing that comes to my mind.
(For someone with 350 posts, I assume you won't have a problem writing this code.)
UDF "FiindDupText" given. It is assumed that sl numbers will be there inside the text of the cell (like in your example).
Code
![]()
Function FindDupText(ByVal Inputval As String) Dim M As Variant Dim T1 As Long, T2 As Long FindDupText = "N" M = Split(Inputval, ".") For T1 = 1 To UBound(M) - 1 For T2 = (T1 + 1) To UBound(M) If Left(M(T1), InStr(1, M(T1), ":") - 1) = Left(M(T2), InStr(1, M(T2), ":") - 1) Then FindDupText = "Y" Exit Function End If Next T2 Next T1 End Function
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks