Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ali ali is offline
external usenet poster
 
Posts: 1
Default Delete all special characters in a selection?


Does anyone know ofa macro that when run will clear all 'special'
characters out of a cell or selection of cells leaving just numbers or
text characters behind?

Thanks


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Delete all special characters in a selection?

It's not hard to write one, though I'm sure it's not the moset
efficient:

Public Sub CleanText()
Dim rConsts As Range
Dim rCell As Range
Dim i As Long
Dim sChar As String
Dim sTemp As String

On Error Resume Next
Set rConsts = Selection.SpecialCells(xlCellTypeConstants)
On Error GoTo 0
If Not rConsts Is Nothing Then
For Each rCell In rConsts
With rCell
For i = 1 To Len(.Text)
sChar = Mid(.Text, i, 1)
If sChar Like "[0-9a-zA-Z]" Then _
sTemp = sTemp & sChar
Next i
.Value = sTemp
End With
sTemp = ""
Next rCell
End If
End Sub



In article ,
ali wrote:

Does anyone know ofa macro that when run will clear all 'special'
characters out of a cell or selection of cells leaving just numbers or
text characters behind?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Delete all special characters in a selection?

If you are talking about cleaning up data that has been imported from the web,
then you might want to take a look at Dave McRitchie's Trimall macro which will
zap that garbage but good!!

http://www.mvps.org/dmcritchie/excel/join.htm#trimall

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
Newsgroups - Where you really can get a free lunch!!
----------------------------------------------------------------------------



"ali" wrote in message
...

Does anyone know ofa macro that when run will clear all 'special'
characters out of a cell or selection of cells leaving just numbers or
text characters behind?

Thanks


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating

financial statements


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.547 / Virus Database: 340 - Release Date: 02/12/2003


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Delete all special characters in a selection?

David's excellent macro zaps extra spaces and non-breaking-spaces
CHAR(160), but doesn't remove any other characters, nor does it
remove single spaces between other characters.

Guess it depends on what the OP considers "special".



In article ,
"Ken Wright" wrote:

If you are talking about cleaning up data that has been imported from the
web,
then you might want to take a look at Dave McRitchie's Trimall macro which
will
zap that garbage but good!!

http://www.mvps.org/dmcritchie/excel/join.htm#trimall

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Delete all special characters in a selection?

Very true - Thanks for the clarification JE.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
Newsgroups - Where you really can get a free lunch!!
----------------------------------------------------------------------------



"J.E. McGimpsey" wrote in message
...
David's excellent macro zaps extra spaces and non-breaking-spaces
CHAR(160), but doesn't remove any other characters, nor does it
remove single spaces between other characters.

Guess it depends on what the OP considers "special".



In article ,
"Ken Wright" wrote:

If you are talking about cleaning up data that has been imported from the
web,
then you might want to take a look at Dave McRitchie's Trimall macro which
will
zap that garbage but good!!

http://www.mvps.org/dmcritchie/excel/join.htm#trimall



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.547 / Virus Database: 340 - Release Date: 02/12/2003


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Special Characters sandyboy Excel Worksheet Functions 2 September 19th 07 04:02 PM
Special Characters aftamath Excel Discussion (Misc queries) 1 October 18th 05 11:02 PM
special characters (little box) YuChieh Excel Discussion (Misc queries) 9 June 14th 05 01:41 PM
Special characters Gilles Desjardins Excel Worksheet Functions 2 December 8th 04 04:17 AM


All times are GMT +1. The time now is 12:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"