View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.misc
CliffG CliffG is offline
external usenet poster
 
Posts: 7
Default how do I use macro to find and replace unicode characters

Beautiful, perfect...thank you so much. :) If you have the time and are
inclined, could you give me a brief explaination of what is going on in this
script? I have done some javascript and php (just enough for my own
purposes), so I can usually at least follow the logic in a routine. This one
has me scratching my head. I don't see anything familar like variables being
manipulated. Where do you get ChrW(9566 - X) for example. My curiosity is
overwhelming me.

Thanks again,

Cliff


"Rick Rothstein" wrote:

Okay, try this variation...

Sub ConvertSymbolsToValues()
Dim X As Long
Dim C As Range
With Worksheets("Sheet1").UsedRange
For X = 1 To 3
Set C = .Find(What:=ChrW(9566 - X), LookAt:=xlPart)
If Not C Is Nothing Then
Do
C.Value = Replace(C.Value, ChrW(9566 - X), Format(X / 4, ".##"))
Set C = .FindNext(C)
Loop While Not C Is Nothing
End If
Next
End With
End Sub

--
Rick (MVP - Excel)


"CliffG" wrote in message
...
Hey Rick,

Well, you were right..it works. Yippee Like I said, I'm not a coder, so
I
don't know how (wish I did, I do like to follow the logic). Just two
issues
remain, the first I think you can fix, hopefully the second. The values
.75
and .25 are switched when replaced in the spreadsheet. The .50 is
replaced
correctly.

The second issue is that the replaced values include a zero before the
decimal point, i.e., the replacement values are 0.25, 0.50, 0.75. Many of
the cells already contain a whole number, so for example, 8 becomes 80.50
instead of the desired 8.50.

Thanks for your effort, I really do appreciate it.

"Rick Rothstein" wrote:

You don't integrate it with what the macro recorder gave you... forget
what
the macro recorder gave you... delete it and copy/paste my macro in its
place. Oh, and change the sheet name I used (Sheet6) in the With
statement
to the name of the worksheet where your data at... then, just run the
macro
and it should replace the three symbols you showed me (, and ) with
the
numbers .25, .5 and .75 wherever they appear on the worksheet.

--
Rick (MVP - Excel)