汉语乘法口诀VBA

2022-10-11 14:35:14   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《汉语乘法口诀VBA》,欢迎阅读!
汉语,乘法,口诀,VBA

Sub 汉语乘法口诀()

Dim x%, y%, n%, s$

s = "一二三四五六七八九"

n = 1

Range("A1:H1").Select

ActiveCell.FormulaR1C1 = "汉语乘法口诀表"

With Selection

.Merge

.HorizontalAlignment = xlCenter

.VerticalAlignment = xlCenter

.Font.Size = 48

.Font.ColorIndex = 5

End With

For x = 2 To 10

For y = 1 To n

Cells(x, y).Select

If (x - 1) * y < 10 Then

Cells(x, y).Value = Mid(s, y, 1) & Mid(s, x - 1, 1) & "得" & Mid(s, (x - 1) * y, 1)

Else

If Mid(Format((x - 1) * y, "0"), 2, 1) = "0" Then

Cells(x, y).Value = Mid(s, y, 1) & Mid(s, x - 1, 1) & Mid(s, (x - 1) * y / 10, 1) & "十"

Else

If (x - 1) * y > 10 And (x - 1) * y < 20 Then

Cells(x, y).Value = Mid(s, y, 1) & Mid(s, x - 1, 1) & "十" & Mid(s, Val(Mid(Format((x - 1) * y, "0"), 2, 1)), 1)

Else

Cells(x, y).Value = Mid(s, y, 1) & Mid(s, x - 1, 1) & Mid(s, Val(Mid(Format((x - 1) * y, "0"), 1, 1)), 1) & "十" & Mid(s, Val(Mid(Format((x - 1) * y, "0"), 2, 1)), 1)

End If

End If

End If

With ActiveCell

.Borders.LineStyle = xlDouble

.Borders.Weight = xlThick

.Borders.ColorIndex = 3

.Characters(Start:=1, Length:=1).Font.ColorIndex = 3

.Characters(Start:=2, Length:=1).Font.ColorIndex = 1

.Characters(Start:=3, Length:=1).Font.ColorIndex = 5

.Characters(Start:=4, Length:=1).Font.ColorIndex = 1

.Characters(Start:=5, Length:=2).Font.ColorIndex = 4

End With

Next y

n = n + 1

Next x

Columns("a:i").ColumnWidth = 27

End Sub

本文来源:https://www.wddqxz.cn/457a969bf61fb7360a4c6529.html

相关推荐