将列标题从全部大写更改为仅每个单词的第一个字母的最佳方法是什么?
谢谢
最佳答案
与 合作WorksheetFunction.Proper Method (Excel) 它将文本字符串中的第一个字母和文本中的任何其他字母大写,而不是在列标题中设置循环。
例子
Public Sub Example()
Dim Last As Long
Dim i As Long
Last = Cells(1, Columns.Count).End(xlToLeft).Column
Debug.Print Last ' Print on Immdiate Window
With ActiveWorkbook
For i = Last To 1 Step -1
Debug.Print Cells(1, i).Value ' Print on Immdiate Window
Cells(1, i).Value = WorksheetFunction.Proper(Cells(1, i).Value)
Next i
End With
End Sub
关于VBA将单词的第一个字母更改为大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43401499/