|

楼主 |
发表于 2020-5-30 11:57
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
If Left(Z(0), 2) <> "I'" And Z(0) <> "I" Then Z(0) = LCase(Z(0)) '加上这一句可保留非首单词的大写
以上是excel中的一段代码,可以用在word中吗?
完整代码:
Sub Lr()
Application.ScreenUpdating = False
Ar = Range("B1:B" & Cells(Rows.Count, 2).End(xlUp).Row)
For I = 1 To UBound(Ar)
Ar(I, 1) = Trim(Ar(I, 1))
Bd = Right(Ar(I, 1), 1)
Z = Split(Left(Ar(I, 1), Len(Ar(I, 1)) - 1))
If Left(Z(0), 2) <> "I'" And Z(0) <> "I" Then Z(0) = LCase(Z(0)) '加上这一句可保留非首单词的大写
X = Z
Set D0 = CreateObject("Scripting.Dictionary")
Randomize
Do
M = Int(((UBound(Z) + 1) * Rnd) + 1)
If Not D0.Exists(M) Then D0(M) = ""
Loop Until D0.Count = UBound(Z) + 1 Or UBound(Z) = 0
Y = D0.Keys
For J = 0 To UBound(Y)
X(Y(J) - 1) = Z(J)
Next
Cells(I, 3) = Join(X, " ") & Bd
Next I
Application.ScreenUpdating = True
End Sub
|
|