|
Sub CurrencyNumber()
'文本分位符+2位小数
Dim i As Range, Acell As Cell, CR As Range
On Error Resume Next
Application.ScreenUpdating = False
If Selection.Type = 2 Then
For Each i In Selection.Words
If i Like "####*" = True Then
If i.Next Like "." = True And i.Next(wdWord, 2) Like "#*" = True Then
i.SetRange Start:=i.Start, End:=i.Next(wdWord, 2).End
i = Format(i, "Standard")
Else
i = Format(i, "Standard")
End If
End If
Next i
ElseIf Selection.Type = 5 Then
For Each Acell In Selection.Cells
Set CR = ActiveDocument.Range(Acell.Range.Start, Acell.Range.End - 1)
MsgBox CR
If CR Like "####*" = True Then
If CR Like "####.#*" = True Then
Yn = Format(CR, "Standard")
CR.Text = Nn
Else
Yn = Format(CR, "Standard")
CR.Text = Nn
End If
End If
Next Acell
Else
MsgBox "您只能选定文本或者表格之一!", vbOK + vbInformation
End If
Application.ScreenUpdating = True
End Sub
上述语句为对word文本中选定的数值添加分位符并保留2位小数,如果需要保留1位小数,如何修改语句?谢谢
Yn = Format(CR, "Standard") 这样的语句修改后面的"standard"就可以了吧。
|
|