View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
camlad camlad is offline
external usenet poster
 
Posts: 28
Default White space removal

Sorry - back again. Both spaces and non-breaking spaces are removed but
there is something remaining in one cell which remains. I paste it, seven
characters on this occasion, here within parenthasis
( )
Pasting into Word and showing hidden characters reveals what look like
spaces. Are there any other forms of space?

This is a spreadsheet which is sent to me occasionally and I need to clear
everything out of the column except text which will be Jan, Feb, Mar,
.......Nov, Dec or the numneral 2009, 2010, etc. Everything else should go in
order for the rest of my programming to work properly.

How can I find what these other characters are or have I to find some way of
testing every character and deleting everything except those which appear in
Jan, Feb, Mar, ......Nov, Dec and 0-9? There must be a better way than that.

Please help.

Camlad


"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
What does "^w" mean to you?

Try this to remove all spaces.

Public Sub Strip_WhiteSpace()
Selection.Replace what:=" ", _
replacement:="", lookat:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End Sub

If the spaces are html non-breaking spaces.

Public Sub Strip_WhiteSpace()
With Selection
.Replace what:=Chr(160), replacement:="", _
lookat:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
.Replace what:=" ", _
replacement:="", lookat:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End With
End Sub


Gord Dibben MS Excel MVP



On Wed, 14 Oct 2009 18:21:06 +0100, "camlad"
wrote:

I need to remove white space from a range so I recorded the following
which
did not work.



How can I remove all spaces in a range?



Range("A1:A535").Select

Selection.Replace What:="^w", Replacement:="", LookAt:=xlPart, _

SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _

ReplaceFormat:=False



Camlad