求优化千分位
这个宏是给数字加千分位并补足小数点后两位,但是3位数一下的数不会被处理希望大佬改一下,使之也可以给小于3位数的数字补足小数点后两位
程序代码:
Sub 加千位符() '加千位符 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