Find similar items from a two fields.
Try the below....which will compare the numeric pieces alone..
Sub Macro()
Dim str1 As String
Dim str2 As String
str1 = "I-11524A"
str2 = "I11524B"
If GetNumericString(str1) = GetNumericString(str2) Then
MsgBox "Similar"
End If
End Sub
Function GetNumericString(strData As String) As String
For inttemp = 1 To Len(strData)
If IsNumeric(Mid(strData, inttemp, 1)) Then
GetNumericString = GetNumericString & Mid(strData, inttemp, 1)
End If
Next
End Function
If this post helps click Yes
---------------
Jacob Skaria
"Heera Chavan" wrote:
I need to write a long script for this...any way I am writing a script with
the help of worksheet function SEARCH which is quite similar to your
idea......
Thank you for your support.
"Jacob Skaria" wrote:
You can check for the first n characters (based on the sepcification and your
requirement) using either LEFT() or using LIKE()...
Dim str1 As String
Dim str2 As String
str1 = "I-11524A"
str2 = "I-11525B"
If str1 Like Left(str2, 6) & "*" Then
MsgBox "Similar"
End If
If this post helps click Yes
---------------
Jacob Skaria
"Heera Chavan" wrote:
Hi,
I am really in a tight spot now.
I need macro which will compare two strings if they are similar.
For example:
StringA = I-11524A
StringB = I-11525B
StringC = I-11525
Now these three string are similar and need a utility which will compare
these strings and highlight them if they are similar.
I tried two three codes like StrComp(str1, str2, vbTextCompare) but it did
not work.
Kindly help.
Regards
Heera Chavan
|