如果在A列中等于或少于4个字母,我如何大写缩写?
我无法在网上找到具体处理缩写的内容。
答案 0 :(得分:3)
UCASE(“string”)将起作用。
Sub stringtest()
If Len(Range("A1")) < 5 Then
Range("A1") = UCase(Range("A1"))
End If
End Sub
答案 1 :(得分:3)
在带阵列的单张照片中(对于 A1:A50000 ),使用工作表函数[a1:A50000] = Application.Evaluate("=IF(len(A1:A50000)<5,Proper(A1:a50000),a1:a50000)")
:
time1
6/15/16 8:00
6/15/16 9:00
6/15/16 10:00
6/16/16 8:00
6/16/16 9:00
6/17/16 8:00
6/18/16 8:00
6/18/16 8:30
6/18/16 9:10
6/19/16 8:00
6/20/16 8:00
6/20/16 11:00
time2
6/15/16 7:58
6/16/16 8:03
6/16/16 9:01
6/17/16 8:00
6/18/16 8:02
6/19/16 8:00
6/20/16 8:00
答案 2 :(得分:1)
这是一个循环。这假设A列中的每个单元格都会包含其中的内容,直到完成为止 - 它将在A列中的第一个空单元格上停止。
Sub initCaps()
Dim intRow As Integer
Dim aryWords() As String
Dim firstWord As String
Dim strNew As String
intRow = 1
Do Until Range("A" & intRow) = ""'Look for a blank call in A, then stop.
aryWords() = (split(Range("A" & intRow), " "))'Make an array of the cell.
firstWord = aryWords(0)'Get the first word.
If Len(firstWord) < 5 Then'Test the first word length.
firstWord = UCase(firstWord)'Change it to upper case.
strNew = firstWord & " "'Add a space to re-build the string
If UBound(aryWords()) > 0 Then
For I = 1 To UBound(aryWords())
strNew = strNew & aryWords(I) & " "'Put back the rest of the words.
Next
End If
Range("A" & intRow) = strNew'Put it back into the cell, modified.
Erase aryWords()
firstWord = ""
strNew = ""
Else
Erase aryWords()'Clean up.
firstWord = ""
strNew = ""
End If
intRow = intRow + 1
Loop'Do it again!
End Sub
祝你好运!