ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Use Formula to sort two strings (https://www.excelbanter.com/excel-worksheet-functions/173048-use-formula-sort-two-strings.html)

Ray Ray

Use Formula to sort two strings
 
Dear experts

I design the following spreadsheet. Please advise how I can achieve the
result on column C (i.e. it sorts column A and B in ascending order, and puts
the smaller string in the front and the bigger one at the back)?

A B C
1 Atlanta Los Angeles Atlanta-Los Angeles
2 Orlando Chicago Chicago-Orlando
3 Mexico City Miami Mexico City-Miami


--
Best regards
Ray Ray

Mike H

Use Formula to sort two strings
 
Put this in C1 and drag down.

=IF(LEN(A1)<LEN(B1),A1&" "&B1,B1&" "&A1)

Mike

"Ray Ray" wrote:

Dear experts

I design the following spreadsheet. Please advise how I can achieve the
result on column C (i.e. it sorts column A and B in ascending order, and puts
the smaller string in the front and the bigger one at the back)?

A B C
1 Atlanta Los Angeles Atlanta-Los Angeles
2 Orlando Chicago Chicago-Orlando
3 Mexico City Miami Mexico City-Miami


--
Best regards
Ray Ray


David Biddulph[_2_]

Use Formula to sort two strings
 
From the look of the OP's example, perhaps he wants:
=IF(A1<B1,A1&"-"&B1,B1&"-"&A1)
--
David Biddulph

"Mike H" wrote in message
...
Put this in C1 and drag down.

=IF(LEN(A1)<LEN(B1),A1&" "&B1,B1&" "&A1)


"Ray Ray" wrote:

Dear experts

I design the following spreadsheet. Please advise how I can achieve the
result on column C (i.e. it sorts column A and B in ascending order, and
puts
the smaller string in the front and the bigger one at the back)?

A B C
1 Atlanta Los Angeles Atlanta-Los Angeles
2 Orlando Chicago Chicago-Orlando
3 Mexico City Miami Mexico City-Miami
--
Best regards
Ray Ray





All times are GMT +1. The time now is 06:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com