Remove leading non-displayable characters from cell

AjohnWoods

New Member
Joined
Jul 13, 2017
Messages
2
Office Version
  1. 365
Platform
  1. Windows
When I retrieve data from SQL table, the cell content always has leading non-displayable characters, which I think are carriage returns, that need to be removed

For example:
1628159765240.png

here is the same using a text editor that shows the cell contents in HEX values
1628159460589.png


It is the leading 0D 0A 0D 0A 0D 0A that I want to remove
using CLEAN is no good, as that also removes the 0D 0A from the middle of the cell also, I need to keep those
could care less about those that trail the text block

As the spreadsheet is generated by another program, I need to avoid using VBA or macros.
A formula is the optimal solution here.


(Office 365, Windows 10)
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi & welcome to MrExcel.
How about
Excel Formula:
=LET(split,MID(A2,SEQUENCE(LEN(A2)),1),MID(A2,MIN(IF(AND(split<>CHAR(10),split<>CHAR(13)),SEQUENCE(LEN(A2)),"")),LEN(A2)))
 
Upvote 0
Oops, it should be
Excel Formula:
=LET(split,MID(A2,SEQUENCE(LEN(A2)),1),MID(A2,MIN(IF((split<>CHAR(10))*(split<>CHAR(13)),SEQUENCE(LEN(A2)),"")),LEN(A2)))
 
Upvote 0
Thanks Fluff, after also applying wrap text to the cell it works.
Problem solved!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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