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