我是否有任何公式可以在Excel中用于将句点后的第一个字母大写?我在一个单元格中有多个句子,每个句子用句点分隔。
我已经尝试了PROPER
FUNCTION以及UPPER
FUNCTION,但我没有得到我想要的结果。
答案 0 :(得分:0)
以下公式可能适合您:
=SUBSTITUTE(SUBSTITUTE(PROPER(SUBSTITUTE(SUBSTITUTE(LOWER(A1),". ","9z9")," ","zxz")),"9Z9",". "),"zxz"," ")
它基本上是SUBSTITUTE
句点和空格,有3个字符的字符串来欺骗PROPER
代码,好像每个句子只是一个单词。然后用句点和空格重新SUBSTITUTE
字符串。
当以下代码输入到Excel文件中的模块时。我们将能够使用自定义公式sCase
来实现我们的需求。对于此解决方案,积分将转至here。
Public Function sCase(ByRef strIn As String) As String
Dim bArr() As Byte, i As Long, i2 As Long
If strIn = vbNullString Then Exit Function
Let bArr = strIn
Select Case bArr(0)
Case 97 To 122
bArr(0) = bArr(0) - 32
End Select
For i = 2 To UBound(bArr) Step 2
Select Case bArr(i)
Case 105
If Not i = UBound(bArr) - 1 Then
Select Case bArr(i + 2)
Case 32, 33, 39, 44, 46, 58, 59, 63, 148, 160
If bArr(i - 2) = 32 Then _
bArr(i) = bArr(i) - 32
End Select
ElseIf bArr(i - 2) = 32 Then _
bArr(i) = bArr(i) - 32
End If
Case 33, 46, 58, 63
For i2 = i + 2 To UBound(bArr) Step 2
Select Case bArr(i2)
Case 97 To 122
bArr(i2) = bArr(i2) - 32
i = i2: Exit For
End Select
Select Case bArr(i2)
Case 32, 33, 46, 63, 160
Case Else
i = i2: Exit For
End Select
Next
End Select
Next
sCase = bArr
End Function