G
gregg098
I am trying to write a macro which searches through a document for a
temperature value such as 395 °F and will convert it to celcius and display
both values in the format 395 °F (xxx °C). I have tried all sorts of things
and cannot get the code to find the temperature values and process it. Does
anyone have any suggestions?
Public Sub macro4()
Dim oRg As Range
Set oRg = ActiveDocument.Range
Dim sText
With oRg.Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
.MatchWildcards = True
.Text = ("[0-9]{1-4} °F")
.Forward = True
.Wrap = wdFindContinue
Do While .Execute
oRg.Text = ((5 / 9) * ((Left(oRg.Text, Len(oRg.Text) - 3)) - 32))
oRg.Collapse Direction:=wdCollapseEnd
Loop
End With
End Sub
This code works if I have it find a specifc value, but not if I use the
[0-9]{1-4} values. Also, my output does not put it in the format I specified
above, I just want to get it to work first. Also, I would like the output to
be no more than one decimal place.
Thanks for the help
temperature value such as 395 °F and will convert it to celcius and display
both values in the format 395 °F (xxx °C). I have tried all sorts of things
and cannot get the code to find the temperature values and process it. Does
anyone have any suggestions?
Public Sub macro4()
Dim oRg As Range
Set oRg = ActiveDocument.Range
Dim sText
With oRg.Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
.MatchWildcards = True
.Text = ("[0-9]{1-4} °F")
.Forward = True
.Wrap = wdFindContinue
Do While .Execute
oRg.Text = ((5 / 9) * ((Left(oRg.Text, Len(oRg.Text) - 3)) - 32))
oRg.Collapse Direction:=wdCollapseEnd
Loop
End With
End Sub
This code works if I have it find a specifc value, but not if I use the
[0-9]{1-4} values. Also, my output does not put it in the format I specified
above, I just want to get it to work first. Also, I would like the output to
be no more than one decimal place.
Thanks for the help