![]() |
String Comparison Not Returning Expected Result
The comparison is coded thusly: ------------------------------------------------------------- If .Cells(rowNum_FirstData, mySortCol).Value _ < .Cells(rowNum_LastData_Revised, mySortCol).Value Then... ------------------------------------------------------------- But it's case-sensitive. To wit: ------------------------------------------------ ?("aaa" < "zzz") True ?("aaa" < "Zzz") False ?("aaa, ABN AMRO Bank" < "Yorktown Capital LLC") False ------------------------------------------------ Basically, I want to determine whether a column is in ascending or descending order so I can sort it to the opposite order. My kneejerk is to Dim a couple of strings, uCase the values in question into them, and then do the comparison on the Dim-d strings. Is there a good-right-and-holy path to follow here? -- PeteCresswell |
String Comparison Not Returning Expected Result
If your sort command ignores case then do this
?(ucase("aaa") < ucase("zzz")) "(PeteCresswell)" wrote: The comparison is coded thusly: ------------------------------------------------------------- If .Cells(rowNum_FirstData, mySortCol).Value _ < .Cells(rowNum_LastData_Revised, mySortCol).Value Then... ------------------------------------------------------------- But it's case-sensitive. To wit: ------------------------------------------------ ?("aaa" < "zzz") True ?("aaa" < "Zzz") False ?("aaa, ABN AMRO Bank" < "Yorktown Capital LLC") False ------------------------------------------------ Basically, I want to determine whether a column is in ascending or descending order so I can sort it to the opposite order. My kneejerk is to Dim a couple of strings, uCase the values in question into them, and then do the comparison on the Dim-d strings. Is there a good-right-and-holy path to follow here? -- PeteCresswell |
String Comparison Not Returning Expected Result
Per Joel:
If your sort command ignores case then do this ?(ucase("aaa") < ucase("zzz")) Sounds like maybe there's a Sort command argument to tell it whether or not to consider case. I'll take a look. -- PeteCresswell |
All times are GMT +1. The time now is 02:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com