Large Excel Email list with Non printing character

A

Alhalford

Hello all!

I have a large email list in Excel and it comes with non printin
characters leading and trailing. I have used both TRIM and CLEA
functions, neither work all the way. I am wondering if there is a
add-in for this or a program that would clean these? At this point I a
having to do this by hand... wasting LOTS of time!

Please help!!! :
 
G

GS

Alhalford wrote :
Hello all!

I have a large email list in Excel and it comes with non printing
characters leading and trailing. I have used both TRIM and CLEAN
functions, neither work all the way. I am wondering if there is an
add-in for this or a program that would clean these? At this point I
am having to do this by hand... wasting LOTS of time!

Please help!!! :)

That's typical of imported lists that are delimited by carriage returns
and/or linefeeds. Here's a reusable function I use that will filter out
unwanted characters. It allows all alpha-numeric characters by default,
and you can specify other characters to be included. (In the case of
email addresses: "@-._" are the most common IncludeChars)

Function FilterString(ByVal TextIn As String, _
Optional IncludeChars As String, _
Optional IncludeLetters As Boolean = True, _
Optional IncludeNumbers As Boolean = True) As String
' Filters out all unwanted characters in a string.
' Args: TextIn The string being filtered.
' IncludeChars [Optional] Any characters to keep.
' IncludeLetters [Optional] Keeps any letters. Default=True
' IncludeNumbers [Optional] Keeps any numbers. Default=True
'
' Returns: String containing only the wanted characters.

Const sSource As String = "FilterString()"

'The basic characters to always keep
Const sLetters As String = "abcdefghijklmnopqrstuvwxyz"
Const sNumbers As String = "0123456789"

Dim i As Long, CharsToKeep As String

CharsToKeep = IncludeChars
If IncludeLetters Then _
CharsToKeep = CharsToKeep & sLetters & UCase(sLetters)
If IncludeNumbers Then _
CharsToKeep = CharsToKeep & sNumbers

For i = 1 To Len(TextIn)
If InStr(CharsToKeep, Mid$(TextIn, i, 1)) Then _
FilterString = FilterString & Mid$(TextIn, i, 1)
Next
End Function 'FilterString()

To use it in a cell formula:
(Assumes email addresses in col A, starting in A2)

In col B2, type ...

=filterstring(a1,"@-._")

...and copy down.

If you store the function in PERSONAL.XLS then to use it in other
workbooks you need to prepend the workbook name like this...

=personal.xls!filterstring(a1,"@-._")

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
G

GS

I see my reader has added link format to my IncludeChars string. To
clarify, it consists of the AT symbol (Shift+2), a hyphen, a period,
and an underscore.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
G

GS

Oops! Sorry about the typos...
In col B2, type ...
=filterstring(a2,"@-._")

..and copy down.

If you store the function in PERSONAL.XLS then to use it in other
workbooks you need to prepend the workbook name like this...
=personal.xls!filterstring(a2,"@-._")

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top