c数字

  1. c数字

c数字

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Sub 千分位符(control As IRibbonControl) '数字-千分位符
On Error Resume Next
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 IsNumeric(i) Then
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
NC = Format(i, "#,##0.00;-#,##0.00; ")
i.Text = NC
Else
NC = Format(i, "#,##0.00;-#,##0.00; ")
i.Text = NC
End If
End If
End If
Next i
ElseIf Selection.Type = 4 Or Selection.Type = 5 Then '竖形表格(5为横形表格)
For Each Acell In Selection.Cells
Set CR = ActiveDocument.Range(Acell.Range.Start, Acell.Range.End - 1)
' MsgBox CR
If CR Like "-####*" Or "-####.#*" = True Then
Yn = Format(CR, "#,##0.00;-#,##0.00; ")
CR.Text = Yn
Else
If CR Like "####*" Or "####.#*" = True Then
Yn = Format(CR, "#,##0.00;-#,##0.00; ")
CR.Text = Yn
End If
End If
Next Acell
Else
MsgBox "您只能选定文本或者表格之一!", vbOK + vbInformation
End If
Application.ScreenUpdating = True
Application.Activate
End Sub
Sub 除以一万(control As IRibbonControl)
Application.ScreenUpdating = False
If Selection.Type = 2 Then
If IsNumeric(Selection.Text) Then
i = Selection.Text
P = i / 10000
q = Format(Round(P, 2), "#,##0.00;-#,##0.00; ")
Selection.Text = q & "万"
End If
ElseIf Selection.Type = 5 Or Selection.Type = 4 Then
For Each Acell In Selection.Cells
Set CR = ActiveDocument.Range(Acell.Range.Start, Acell.Range.End - 1)
'MsgBox CR
If IsNumeric(CR.Text) Then
i = CR.Text
P = i / 10000
q = Format(Round(P, 2), "#,##0.00;-#,##0.00; ")
CR.Text = q & "万"
End If
Next
End If
Application.ScreenUpdating = True
End Sub
Sub 乘百(control As IRibbonControl)
Application.ScreenUpdating = False
If Selection.Type = 2 Then
If IsNumeric(Selection.Text) Then
i = Selection.Text
P = i * 100
q = Format(Round(P, 2), "#,##0.00;-#,##0.00; ")
Selection.Text = q & "%"
End If
ElseIf Selection.Type = 5 Or Selection.Type = 4 Then
For Each Acell In Selection.Cells
Set CR = ActiveDocument.Range(Acell.Range.Start, Acell.Range.End - 1)
'MsgBox CR
If IsNumeric(CR.Text) Then
i = CR.Text
P = i * 100
q = Format(Round(P, 2), "#,##0.00;-#,##0.00; ")
CR.Text = q & "%"
End If
Next
End If
Application.ScreenUpdating = True
End Sub

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 richffan@outlook.com

文章标题:c数字

字数:467

本文作者:Rich Fan

发布时间:2023-05-15, 00:00:00

最后更新:2024-02-27, 08:17:39

原始链接:http://fanrich.github.io/2023/05/14/VBA/%E5%BA%95%E7%A8%BF%E5%B0%8F%E5%B8%AE%E6%89%8B%E4%BB%A3%E7%A0%81/c%E6%95%B0%E5%AD%97/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。