Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing a Char from field

Status
Not open for further replies.

pkw25

MIS
Mar 20, 2002
46
IE
Hi All

I have a file that contains characters that should be removed from certain fields. For example for the name O'BRIEN I want to remove the ' so that I'm left with OBRIEN. The unwanted character can be in different places in different records. Is there a looping macro that could remove all characters with that ASCII value from a column of records. Any help would be greatly appreciated

Paraic
 
Not pretty but:

sub removeunwanted(dastring,unwanted)
dim locale as integer

Do
locale = InStr(dastring, unwanted)
If locale <> 0 Then dastring = Left(dastring, locale - 1) _ + Right(dastring, Len(dastring) - locale)
Loop Until locale = 0
end sub

and this call be called by:
call removeunwanted(dastring,&quot;'&quot;)
call removeunwanted(dastring,&quot;£&quot;)

or if there are a load of characters, load them into an array and loop.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top