Substitute Formula for 18 Characters?

Southerncentralrain

Board Regular
Joined
Jul 6, 2008
Messages
115
I am trying to write a formula to replace common non-ASCII characters that are produced in word with the ASCII equivalent. Below is the list of non-ASCII characters:

<table border="0" cellpadding="0" cellspacing="0" width="64"><col style="width:48pt" width="64"> <tbody><tr style="height:15.0pt" height="20"> <td style="height:15.0pt;width:48pt" height="20" width="64">£</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">©</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">®</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">²</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">¼</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">½</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">¾</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">í</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">–</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">—</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">’</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">“</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">”</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">•</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">…</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">…</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">℠</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">™</td> </tr> </tbody></table>
I am looking to replace them with the following ASCII characters:

<table border="0" cellpadding="0" cellspacing="0" width="64"><col style="width:48pt" width="64"> <tbody><tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;width:48pt" height="20" width="64">gbp</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">(c)</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">(r)</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">^2</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">1/4</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">1/2</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">3/4</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">i</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">-</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">-</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">'</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">"</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">"</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">*</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">...</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">...</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">(sm)</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20">(tm)</td> </tr> </tbody></table>
Is this possible to do? Thanks in advance for any help with this.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Thanks for your response but I believe it has a limit of 8. I actually just recorded a Macro and it seems to be working very good for this. Thanks again for your time.
 
Upvote 0
I actually just recorded a Macro and it seems to be working very good for this.
You originally asked for a formula, so I assumed you wanted to preserve your original text but be able to work with it by replacing the characters via a formula for use in different cells. If that is the case, here is a UDF you can use...

Code:
Function FixWordChars(S As String) As String
  Dim X As Long, CharPostion As Long, FindMe As String, ReplaceWith As String, Replacements() As String
  Const CharactersToBeReplaced As String = "£©®²¼½¾í–—’“”•……?™"
  Const ReplacementText As String = "gbp,(c),(r),^2,1/4,1/2,3/4,i,-,-,',"","",*,...,...,(sm),(tm)"  'Note: No spaces around commas
  Replacements = Split(ReplacementText, ",")
  FixWordChars = S
  For X = 1 To Len(CharactersToBeReplaced)
    FindMe = Mid(CharactersToBeReplaced, X, 1)
    CharPostion = InStr(CharactersToBeReplaced, FindMe)
    ReplaceWith = Replacements(CharPostion - 1)
    FixWordChars = Replace(FixWordChars, FindMe, ReplaceWith)
  Next
End Function
I know you said you have a working macro, but the above can be recast into a macro quite easily, so I figured I would show you it.

Code:
Sub FixWordChars()
  Dim X As Long, CharPostion As Long, FindMe As String, ReplaceWith As String, Cell As Range, Replacements() As String
  Const CharactersToBeReplaced As String = "£©®²¼½¾í–—’“”•……?™"
  Const ReplacementText As String = "gbp,(c),(r),^2,1/4,1/2,3/4,i,-,-,',"","",*,...,...,(sm),(tm)"  'Note: No spaces around commas
  Replacements = Split(ReplacementText, ",")
  For Each Cell In Selection
    For X = 1 To Len(CharactersToBeReplaced)
      FindMe = Mid(CharactersToBeReplaced, X, 1)
      CharPostion = InStr(CharactersToBeReplaced, FindMe)
      ReplaceWith = Replacements(CharPostion - 1)
      Cell.Value = Replace(Cell.Value, FindMe, ReplaceWith)
    Next
  Next
End Sub
Note that this macro works on the selection of cells, so select your cells before running it... the selected cells do not all have to have characters to be replaced, but the less cells you make the macro process, the faster it will complete its task.
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,317
Members
452,905
Latest member
deadwings

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top