How to sort a column which can be a string or a number

Hi,

I use below codes a lot in CompareRows event to sort ‘Numeric columns’. It works well.
However, for one feature, I should just use one Listbox for displaying the result of many database queries.
As you can imagine, the query results in different column types so for instance the third column can be a string but it can be a numeric value with other query.

Is there any way for me to keep the correct sorting for only numeric columns? Probably with column name?
I mean the specific columns values are not always numeric values.

  Select Case column
  Case 1 to 10      
    If Val(Me.Cell(row1, column)) < Val(Me.Cell(row2, column)) Then
      result = -1
    ElseIf Val(Me.Cell(row1, column)) > Val(Me.Cell(row2, column)) Then
      result = 1
    Else
      result = 0
    End If
	
  Return True
  
  End Select

Test the cell values with IsNumeric? If both are compare by turning them into doubles with Val() before comparing. If not compare them as strings.

You could also put the actual values in the cell tags and sort on those.

[IsNumeric] is the key!
Below codes work great. Thank you so much.

  Select Case column
  Case 4   
    
    If IsNumeric(Me.Cell(row1, column)) Then 'Numeric
      
      If Val(Me.Cell(row1, column)) < Val(Me.Cell(row2, column)) Then
        result = -1
      ElseIf Val(Me.Cell(row1, column)) > Val(Me.Cell(row2, column)) Then
        result = 1
      Else
        result = 0
      End If
      
    Else 'Non-Numeric
      
      If Me.Cell(row1, column) < Me.Cell(row2, column) Then
        result = -1
      ElseIf Me.Cell(row1, column) > Me.Cell(row2, column) Then
        result = 1
      Else
        result = 0
      End If
      
    End If
    
    Return True
    
  End Select