COMPARE function
Compares 2 values using the same collating sequence as Excel’s SORT. Returns -1 if the first value is less than the second value, 0 if they are equal and +1 if the first value is greater than the second value.
COMPARE Syntax
COMPARE (Value1, Value2, Case_Sensitive)
Value1 (required)
The Value to compare with Value 2. Can be a string, a number or a logical value.
Value2 (required)
The Value to compare with Value 1. Can be a string, a number or a logical value.
Case-Sensitive (optional, default False)
If TRUE then the comparison of 2 Text values will be done in a case-sensitive manner.
Remarks
Returns #Value if either of Value1 or Value 2 are errors.
Returns a negative value if Value1 is less than Value2
Returns zero if Value1 is equal to Value2
Returns a positive value if Value1 is greater than Value2
The comparison is done using Excel’s sorting sequence rules:
Numbers <text <logical
Lower-case characters<upper-case characters
Numbers stored as text are always treated as text rather than numbers
The comparison of characters and some character pairs is dependent on the Locale collating sequence in force when the Excel session was started.
|