|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 miarua 于 2019-6-18 16:15 编辑
Private Sub 单位统一_Click()
Dim a() As String
a = Split(Form1.Text1.Text, ",")
For i = 0 To UBound(a)
With Selection
With .Find
.ClearFormatting
If a(i) = "KN" Or a(i) = "kn" Or a(i) = "Kn" Then
.Execute "KN", , , 1, , , , , , LCase(Trim(Mid(a(i), 1, 1))) & UCase(Mid(a(i), 2, Len(a(i)))), 2
.Replacement.Font.Color = wdColorRed
.Execute "kn", , , 1, , , , , , LCase(Trim(Mid(a(i), 1, 1))) & UCase(Mid(a(i), 2, Len(a(i)))), 2
.Replacement.Font.Color = wdColorRed
.Execute "Kn", , , 1, , , , , , LCase(Trim(Mid(a(i), 1, 1))) & UCase(Mid(a(i), 2, Len(a(i)))), 2
.Replacement.Font.Color = wdColorRed
End If
end with
end with
next
end sub
***********************************************
上述代码可实现将单位“千牛”都统一成"kN",但按照同样方式实现cm,mm,km,m/s,却不行
If a(i) = "CM" Or a(i) = "Cm" Or a(i) = "cM" Then
.Execute "CM", , , 1, , , , , , UCase(Trim(Mid(a(i), 1, 1))) & LCase(Mid(a(i), 2, Len(a(i)))), 2
.Replacement.Font.Color = wdColorRed
.Execute "Cm", , , 1, , , , , , UCase(Trim(Mid(a(i), 1, 1))) & LCase(Mid(a(i), 2, Len(a(i)))), 2
.Replacement.Font.Color = wdColorRed
.Execute "cM", , , 1, , , , , , UCase(Trim(Mid(a(i), 1, 1))) & LCase(Mid(a(i), 2, Len(a(i)))), 2
.Replacement.Font.Color = wdColorRed
End If
If a(i) = "KM" Or a(i) = "Km" Or a(i) = "kM" Then
.Execute "KM", , , 1, , , , , , LCase(Trim(Mid(a(i), 1, 1)) & Mid(a(i), 2, Len(a(i)) - 1)), 2
.Replacement.Font.Color = wdColorRed
.Execute "Km", , , 1, , , , , , LCase(Trim(Mid(a(i), 1, 1)) & Mid(a(i), 2, Len(a(i)) - 1)), 2
.Replacement.Font.Color = wdColorRed
.Execute "kM", , , 1, , , , , , LCase(Trim(Mid(a(i), 1, 1)) & Mid(a(i), 2, Len(a(i)) - 1)), 2
.Replacement.Font.Color = wdColorRed
End If
If a(i) = "MM" Or a(i) = "mM" Or a(i) = "Mm" Then
.Execute "MM", , , 1, , , , , , LCase(Trim(Mid(a(i), 1, 1)) & Mid(a(i), 2, Len(a(i)) - 1)), 2
.Replacement.Font.Color = wdColorRed
.Execute "mM", , , 1, , , , , , LCase(Trim(Mid(a(i), 1, 1)) & Mid(a(i), 2, Len(a(i)) - 1)), 2
.Replacement.Font.Color = wdColorRed
.Execute "Mm", , , 1, , , , , , LCase(Trim(Mid(a(i), 1, 1)) & Mid(a(i), 2, Len(a(i)) - 1)), 2
.Replacement.Font.Color = wdColorRed
End If
If a(i) = "M/S" Or a(i) = "m/s" Or a(i) = "m/S" Then
.Execute "M/S", , , 1, , , , , , LCase(Trim(Mid(a(i), 1, 1)) & Mid(a(i), 2, Len(a(i)) - 1)), 2
.Replacement.Font.Color = wdColorRed
.Execute "m/s", , , 1, , , , , , LCase(Trim(Mid(a(i), 1, 1)) & Mid(a(i), 2, Len(a(i)) - 1)), 2
.Replacement.Font.Color = wdColorRed
.Execute "m/S", , , 1, , , , , , LCase(Trim(Mid(a(i), 1, 1)) & Mid(a(i), 2, Len(a(i)) - 1)), 2
.Replacement.Font.Color = wdColorRed
End If
|
|