Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VBA将单词的第一个字母更改为大写_Vba_Excel - Fatal编程技术网

VBA将单词的第一个字母更改为大写

VBA将单词的第一个字母更改为大写,vba,excel,Vba,Excel,将列标题从所有大写更改为每个单词的第一个字母的最佳方法是什么 谢谢使用,它将文本字符串中的第一个字母以及文本中除字母以外的任何字符后面的任何其他字母大写,而不是在列标题中设置循环 范例 如@yass所述,使用此cell.Value=WorksheetFunction.property(cell.Value)。在本机VBA中,strconv(“正确”,vbProperCase)是正确的。 Public Sub Example() Dim Last As Long Dim i As

将列标题从所有大写更改为每个单词的第一个字母的最佳方法是什么

谢谢

使用,它将文本字符串中的第一个字母以及文本中除字母以外的任何字符后面的任何其他字母大写,而不是在列标题中设置循环

范例


如@yass所述,使用此cell.Value=WorksheetFunction.property(cell.Value)。在本机VBA中,
strconv(“正确”,vbProperCase)
是正确的。
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