Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / September 2007

Tip: Looking for answers? Try searching our database.

Special Characters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sandyboy - 19 Sep 2007 08:42 GMT
Is there a function in excel that removes special characters (ie: # \ @) from
a cell? Would appreciate prompt reply.

Thanks,

Signature

sandyboy

Mike H - 19 Sep 2007 09:22 GMT
Hi,

One way. Assumes the cells you want to remove these characters from are in
column A but change to suit. This will extract the characters that are in
cell J1 on the active sheet. The pattern provided extracts upper/lower case
letters, numbers and full stop. To add a character use the syntax |[?] to
extract the question mark.

Sub removespecial()
Dim RegExp As Object, Collection As Object, RegMatch As Object
Dim Myrange As Range, C As Range, Outstring As String
   Set RegExp = CreateObject("vbscript.RegExp")
   With RegExp
       .Global = True
       .Pattern = Cells(1, 10).Value 'J1 on active sheet> [A-Z]|\d|[a-z]|[.]
   End With
   Set Myrange = ActiveSheet.Range("a1:a10") 'change to suit
   For Each C In Myrange
       Outstring = ""
       Set Collection = RegExp.Execute(C.Value)
       For Each RegMatch In Collection
           Outstring = Outstring & RegMatch
       Next
       'C.Offset(0, 1) = Outstring
       C.Value = Outstring
   Next

   Set Collection = Nothing
   Set RegExp = Nothing
   Set Myrange = Nothing
End Sub

Mike

> Is there a function in excel that removes special characters (ie: # \ @) from
> a cell? Would appreciate prompt reply.
>
> Thanks,
Teethless mama - 19 Sep 2007 16:02 GMT
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"#",""),"\",""),"@","")

> Is there a function in excel that removes special characters (ie: # \ @) from
> a cell? Would appreciate prompt reply.
>
> Thanks,
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.