Perhaps the following VBA solution using Regular Expressions.
Function FixMyPercentages(target As String) As String
Dim output As String
output = target
With New RegExp
.Global = False
.MultiLine = True
.IgnoreCase = False
.pattern = "\s\d+\.\d+$|^\d+\.\d+\s|\s\d+\.\d+\s"
Dim myMatch As Object, myMatches As Object
Do While .test(output)
Set myMatches = .Execute(output)
For Each myMatch In myMatches
output = .Replace(output, " " & Format$(CDbl(myMatch.Value), "0.00%") & " ")
Next myMatch
Loop
End With
FixMyPercentages = Trim(output)
End Function
To implement this:
- Alt + F11 to open the VB editor (or Developer > Visual Basic.)
- Then Insert > Module
- Paste the below code.
- Add a reference to
Microsoft VBScript Regular Expressions 5.5
under Tools > References - And then use it as a formula in your worksheet.
8
solved How to convert to percentage [closed]