LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How to eliminate spurious data in a string?

Thanks very much.

Two questions:
How can you say Application.Substitute
without saying WorksheetFunction?

Where are these functions in VBA help?

Thanks again,
Peter.

"keepITcool" wrote in message
...

All the are worksheetfunctions...

the first clean takes care of non printing (incl tabs and linefeeds!)
the subst takes care of the chr(160)
the trim takes care of the double spaces in mid text, and the starting
and trailing spaces.

Note the &h denotes hexcodes
&h7 = 7 = tab
&ha = 10 = linefeed
&h20 = 32 = space
&hA0 = 160 = non breaking space


Sub cleanstring()
With activecell
'fill with dirt
.Value = "abc" & Chr$(&H20) & Chr$(&H7) & Chr$(&HA) & Chr$(&HA0)
'clean and trim
'always use application iso application.worksheetfunction
'as this has error handling advantages :)
.Value = Application.Trim( _
Application.Substitute( _
Application.Clean(.Value), Chr(&HA0), vbNullString))

End With
End Sub




keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


Peter Chatterton wrote in message
:

I have a cell that contains X'2020A0' as trailing spaces.
('A0' I am told is a non-breaking space in html)

I've used the following on it:
Application.WorksheetFunction.Clean
RTrim
but can't get them to go away.

Any suggestions would be much appreciated,
and thanks,
Peter.

P.S. The data comes from an external source.







 
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
Excel: Spurious files created on Save Chris Skrimshire Excel Discussion (Misc queries) 1 October 26th 08 11:39 AM
Spurious files created on Save Chris Skrimshire Excel Discussion (Misc queries) 6 October 22nd 08 10:17 PM
Formula to Replace or eliminate any sheetname(s) in formula string EagleOne Excel Discussion (Misc queries) 0 September 20th 06 06:36 PM
to search for a string and affect data if it finds the string? Shwaman Excel Worksheet Functions 1 January 11th 06 12:56 AM
Spurious ComboBox change event Tony Adams Excel Programming 2 June 11th 04 02:35 PM


All times are GMT +1. The time now is 04:20 AM.

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

About Us

"It's about Microsoft Excel"