Waht Formula To Use To Show Content Of A Cell - First Line ONLY?

Dhira

Board Regular
Joined
Feb 23, 2006
Messages
87
Office Version
  1. 2021
Platform
  1. Windows
Cell B1 has:
New York
Los Angeles
Las Vegas
Cell A1 needs to only show
New York (first line of Cell B1)
I tried: =SUBSTITUTE(Len(B1,"%Chr(13)&Chr(10)%",""))
Basically I need to NOT copy anything after the first carriage return in the cell..
Input appreciated.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
They're not carriage returns, they're line feeds:-
Code:
=LEFT(B1,FIND(CHAR(10),B1&CHAR(10)))
 
Upvote 0
Thanks, njimack and Ruddles.

Works perfect. Appreciate it.
 
Upvote 0
You should probably do both CHAR(10) and CHAR(13) since Windows uses one and Mac the other.

=LEFT(LEFT(B1,FIND(CHAR(10),B1&CHAR(10))),FIND(CHAR(13),LEFT(B1,FIND(CHAR(10),B1&CHAR(10)))&CHAR(13)))
 
Upvote 0
Thank you for correcting my correction - knowledge filed away for future use!

Thinks (out loud)... maybe also:-
Code:
 =LEFT(B1,MIN(FIND(CHAR(10),B1&CHAR(10)),FIND(CHAR(13),B1&CHAR(13))))
or:-
Code:
=LEFT(B1,FIND(CHAR(10),SUBSTITUTE(B1,CHAR(13),CHAR(10))&CHAR(10)))
 
Last edited:
Upvote 0
And yet another option...

=LEFT(B1,FIND(CHAR(10),SUBSTITUTE(B1,CHAR(13),CHAR(10))&CHAR(10)))
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,901
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top