AlexandarR
11-16-2015, 07:18 AM
Hi Guys,
I have a big table which have full of decimal values like 1.23, 2.34, etc. But, in some instances there is values like .12, .34, etc. (naked decimals), which are to be changed as 0.12, 0.34, etc. Also, table data has formatted with style "tab-body". Is it possible to find only naked decimal values (.12, .34, etc.) in table cells with style "tab-body".
I am using the following code, but not working. Is there any option in word like "Excel - Find - Match entire cell contents"?
Sub a_BodyText11B()
Dim strFind() As String
Dim oRng As Range
Dim bFound As Boolean
Dim i As Long
strFind = Split("[!0-9].([0-9]@>)|\(.([0-9]@>)", "|")
For i = LBound(strFind) To UBound(strFind)
Set oRng = ActiveDocument.Range
With oRng.Find
Do While .Execute(strFind(i), MatchWildcards:=True, MatchWholeWord:=True)
If oRng.Style = "tab-head" Or oRng.Style = "tab-body" Then
oRng.HighlightColorIndex = wdTurquoise
'oRng.Font.Color = wdColorPink
oRng.Comments.Add oRng, "CE: Naked decimals are not allowed. Ex: .03, add a zero to the left of the decimal: 0.03."
bFound = True
End If
oRng.Collapse wdCollapseEnd
Loop
End With
Next i
lbl_Exit:
Exit Sub
End Sub
Please help :help!!!
Thanks,
Alex
I have a big table which have full of decimal values like 1.23, 2.34, etc. But, in some instances there is values like .12, .34, etc. (naked decimals), which are to be changed as 0.12, 0.34, etc. Also, table data has formatted with style "tab-body". Is it possible to find only naked decimal values (.12, .34, etc.) in table cells with style "tab-body".
I am using the following code, but not working. Is there any option in word like "Excel - Find - Match entire cell contents"?
Sub a_BodyText11B()
Dim strFind() As String
Dim oRng As Range
Dim bFound As Boolean
Dim i As Long
strFind = Split("[!0-9].([0-9]@>)|\(.([0-9]@>)", "|")
For i = LBound(strFind) To UBound(strFind)
Set oRng = ActiveDocument.Range
With oRng.Find
Do While .Execute(strFind(i), MatchWildcards:=True, MatchWholeWord:=True)
If oRng.Style = "tab-head" Or oRng.Style = "tab-body" Then
oRng.HighlightColorIndex = wdTurquoise
'oRng.Font.Color = wdColorPink
oRng.Comments.Add oRng, "CE: Naked decimals are not allowed. Ex: .03, add a zero to the left of the decimal: 0.03."
bFound = True
End If
oRng.Collapse wdCollapseEnd
Loop
End With
Next i
lbl_Exit:
Exit Sub
End Sub
Please help :help!!!
Thanks,
Alex