Re: How do you remove all the symbols?
- From: "Peter T" <peter_t@discussions>
- Date: Fri, 12 May 2006 14:07:37 +0100
The fact the msgbox shows "hidden message oxford st" shows the function is
working.
The function as it stands does not change the original string, it returns a
new changed string. I wrote that way so you can use it as a UDF, eg formula
in a cell, say B1
=RepChars(A1)
If you are only using macros and want to change your original string you can
either work with the original function like this -
Sub Test2()
Dim sOld As String
Dim sNew As String
sOld = "!#£$abc!£$ def)(&*-"
sNew = RepChars(sOld, True, True)
sOld = sNew
MsgBox sOld
End Sub
Or you can dispense with sOld and simply
sOld= RepChars(sOld, True, True)
A different approach is to amend the function to change the original string
within the function. Start by copying the entire function and give it a new
name, eg RepString. Remove "As String" at the end of the function line. Then
change the following two lines
' sTmp = StrConv(bArr, vbUnicode)
' RepString= Replace(sTmp, "#", "")
strIn = StrConv(bArr, vbUnicode)
strIn = Replace(strIn, "#", "")
Also comment or delete the line after the error handler,
' RepString= "error"
While testing also comment the line
On Error Goto errH
To call the function and directly change your string try something like
Sub Test3()
Dim s As String
s = "!#£$abc!£$ def)(&*-"
RepString s, True, True
MsgBox s
End Sub
But remember you can't use this version as a UDF in worksheet formulas.
Hope you understood the purpose of the arguments True, True in the example.
This first instructs remove all the misc characters, the second True/False
to remove the numbers. You would want to pass at least one True or the
function will do nothing.
Regards,
Peter
If you want to change the original string to the new string there are
different ways
"elaine" <elaine216@xxxxxxxxx> wrote in message
news:1147437324.564954.101200@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hi pete,
the first code you posted wasnt working... and I dont really understand
how it works.. and after i run the code, a message box pops up with all
the symbols and 123 oxford st, with hidden message oxford st. I guess
its just show that cos its in the code... but it didnt delete any of my
sumbols or numbers in the column...
.
- References:
- How do you remove all the symbols?
- From: elaine
- Re: How do you remove all the symbols?
- From: Peter T
- Re: How do you remove all the symbols?
- From: elaine
- Re: How do you remove all the symbols?
- From: Peter T
- Re: How do you remove all the symbols?
- From: Peter T
- Re: How do you remove all the symbols?
- From: elaine
- How do you remove all the symbols?
- Prev by Date: Re: Inputbox help...
- Next by Date: Forcing calculation through automation
- Previous by thread: Re: How do you remove all the symbols?
- Next by thread: Re: How do you remove all the symbols?
- Index(es):
Relevant Pages
|