Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is an article/ post you may want to check. The first impression I had on your question is that you may be trying to do a version number comparison. Length and number of dot delimiters in your text could matter greatly.for now please check this,</p> <p><a href="http://www.dbforums.com/microsoft-excel/1670840-compare-version-numbers-return-highest-value.html" rel="nofollow noreferrer">http://www.dbforums.com/microsoft-excel/1670840-compare-version-numbers-return-highest-value.html</a></p> <p>Or else you may try the <code>log</code> as well:</p> <p>=A1*10^(4-INT(LOG(A1))) </p> <p>Or do a replace on trailing <code>.</code> dots and surely the second text becomes a decimal:</p> <p>E.g. 1.3.4 will be 1.34 and 1.3.4.1.3 will be 1.3413</p> <p>1.2.5.6 will be 125.6 and 1.2.4.6.1 will be 124.61</p> <p>PS: not front of a machine. Will provide you with another code I have based on split by dot delimiter and compare.</p> <p>Edit with a function: this will compare two version numbers with any number of dot points, treating it as a string/text. However in the case of 1.3.1 and 1.21.1 this takes 1.21.1 as the highest number.</p> <pre><code>Option Explicit Function versionNumberComparison(ByRef rng1 As Range, ByRef rng2 As Range) As String Dim i As Integer Dim arrVersion1 As Variant, arrVersion2 As Variant Dim strVer1 As String, strVer2 As String Dim bool2 As Boolean, bool1 As Boolean Dim x As Long, y As Long Application.EnableEvents = False If Not IsEmpty(rng1.Value) Then strVer1 = rng1.Value arrVersion1 = Split(rng1.Value, ".") Else versionNumberComparison = "Version number empty" GoTo Zoo End If If Not IsEmpty(rng2.Value) Then strVer2 = rng2.Value arrVersion2 = Split(rng2.Value, ".") Else versionNumberComparison = "Version number empty" GoTo Zoo End If If UBound(arrVersion1) &gt; UBound(arrVersion2) Then x = UBound(arrVersion1) y = UBound(arrVersion2) ElseIf UBound(arrVersion1) &lt; UBound(arrVersion2) Then x = UBound(arrVersion2) y = UBound(arrVersion1) Else x = UBound(arrVersion1) y = x End If i = 0 While i &lt;= y If IsNumeric(arrVersion1(i)) And IsNumeric(arrVersion2(i)) Then If CInt(Trim(arrVersion1(i))) = CInt(Trim(arrVersion2(i))) Then If i = y Then If x &lt;&gt; y Then If Len(strVer1) &gt; Len(strVer2) Then bool1 = True bool2 = False GoTo PrintOut Else bool2 = True bool1 = False GoTo PrintOut End If End If End If bool1 = False bool2 = False ElseIf CInt(Trim(arrVersion1(i))) &gt; CInt(Trim(arrVersion2(i))) Then bool1 = True bool2 = False GoTo PrintOut Else bool2 = True bool1 = False GoTo PrintOut End If Else versionNumberComparison = "Enter Valid version numbers" GoTo Zoo End If i = i + 1 Wend PrintOut: If bool1 Then versionNumberComparison = strVer1 ElseIf bool2 Then versionNumberComparison = strVer2 Else versionNumberComparison = "Both the same" End If Zoo: Application.EnableEvents = True End Function </code></pre> <p>Output:</p> <p><img src="https://i.stack.imgur.com/f2Fc4.jpg" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload