Fast string comparison
Hi Robert,
Am Fri, 15 May 2015 06:03:54 -0700 schrieb Robert Crandal:
Hi Claus. Unfortunately, I will not be comparing strings that
exist on a spreadsheet. I will be comparings strings that are
stored in String variables. So, for example:
then try:
Sub CompStrings()
Dim strA As String, strB As String
Dim i As Long
Dim myComp As Boolean
strA = "right-handed"
strB = "left-handed"
strA = Replace(Replace(strA, "-", ""), "'", "")
strB = Replace(Replace(strB, "-", ""), "'", "")
For i = 1 To Len(strA)
If LCase(Mid(strA, i, 1)) < LCase(Mid(strB, i, 1)) Then
myComp = IIf(Asc(LCase(Mid(strA, i, 1))) < _
Asc(LCase(Mid(strB, i, 1))), True, False)
MsgBox myComp
Exit For
End If
Next
End Sub
If your strings are in a 2D Array you could loop through the array and
insert the result into it and then write the array to a spreadsheet.
Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
|