Solved

Replace character

Posted on 2012-12-28
5
211 Views
Last Modified: 2013-01-21
I am trying to clean up some imported data that has numerous special characters eg "-","/","\"," ").i would like to replace the  special characters with ","(chr(44)).I need the most efficient way of doing this.Thanks
0
Comment
Question by:Svgmassive
5 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38726982
Where is your data coming from?  

What application do you want to do the "cleanup" from (Access or Excel)?

Is this for a single field in the data, or multiple fields?

Could some of these characters ("\") be delimiters for file names or in hyperlinks that should not be removed?
0
 

Author Comment

by:Svgmassive
ID: 38727079
the application is ms access,they are not delimiters and the characters can be removed.Thanks
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38727141
one or more fields?

You can create a simple Update query, something like:

UPDATE yourTable
SET yourField = Replace([yourField], "/", chr$(44))

If you need to do this for multiple fields, and multiple characters, you could create an array of the characters and a second array of field names, then create two loops (one for fields, the other for characters) and run this query inside the inner loop.

This will not work if your table is a Linked Excel worksheet, it will only work if the data has been imported into Access.
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 38727553
MyData = Replace(MyData, "/",chr(44))

Do the above for each special character.
0
 
LVL 40

Accepted Solution

by:
als315 earned 500 total points
ID: 38727792
If this operation should be done only once, you can open table and use standard find & replace (Find button on ribbon or Ctrl+F). If it should be done many time, use update query with this function:
Function rpl(A As String) As String
Dim Arr As Variant, i As Integer
rpl = A
Arr = Array("-", "/", "\", " ")
For i = 0 To UBound(Arr)
    rpl = Replace(rpl, Arr(i), Chr(44))
Next i
End Function

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question