excel - 使用VBA将每个单词的第一个字母大写

标签 excel vba

如何使用 VBA 格式化 Excel 工作表中的单词,使每个单词中的第一个字母大写,后跟小写字母?

最佳答案

PROPER 函数应该有帮助。请参阅this了解详情。

使用 VBA

Sub Demo()
    Dim ws As Worksheet
    Dim rng As Range, cel As Range
    Dim lastRow As Long

    Set ws = ThisWorkbook.Sheets("Sheet3")  'change Sheet3 to data sheet
    With ws
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        For Each cel In .Range("A1:A" & lastRow)
            cel.Offset(0, 1).Value = Application.Proper(cel.Value)
        Next
    End With
End Sub

使用公式

=PROPER(A1)

enter image description here

关于excel - 使用VBA将每个单词的第一个字母大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46886419/

相关文章:

vba - Excel VBA : Date Comparison

excel - 在 Ms Excel VBA 中将 2 对数据与循环进行比较

excel - 双 'for' 循环 - 只有内部循环在工作

excel - Azure机器学习工作室: how to add a dataset from a local Excel file?

excel - 如何在 Access VBA 中检查 Excel 时间值?

vba - Outlook VBA 宏无法识别

c# - VSTO 备选方案

arrays - 突出显示变体数组中的单元格

excel - VBA函数根据字符串中特定字符的位置带回字符串的左侧

vba - 验证各种条件