I'm looking to take a text string and remove everything except the carriage returns and normal text (so other control characters, spaces, bullet points and a few other bits of junk). However
CLEAN(A1)
strips the carriage returns too.
I've tried a string of nested
SUBSTITUTE(A1, CHAR(000), "")
SUBSTITUTE(A1, CHAR(001), "")
etc
but it keeps defaulting to
SUBSTITUTE(A1, CHAR(0), "")
SUBSTITUTE(A1, CHAR(1), "")
and giving me an error. Any help?
Not very experienced in VBA, though I could gather some basics with a bit of googling.
Assuming that you want to remove:
then consider the following User Defined Function:
This will retain both ASCII-10 and ASCII-13, if you also want to retain the space character, just remove the 32 from the
Array()
statement.User Defined Functions (UDFs) are very easy to install and use:
If you save the workbook, the UDF will be saved with it. If you are using a version of Excel later then 2003, you must save the file as .xlsm rather than .xlsx
To remove the UDF:
To use the UDF from Excel:
To learn more about macros in general, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
and
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
and for specifics on UDFs, see:
http://www.cpearson.com/excel/WritingFunctionsInVBA.aspx
Macros must be enabled for this to work!