Excel VBA Macro: Capitalize First Letter of Every Word in a (Static/Dynamic) Range of Strings

Опубликовано: 04 Январь 2025
на канале: greggowaffles
521
12

Excel VBA Macro: Capitalize First Letter of Every Word in a (Static/Dynamic) Range of Strings

💥Subscribe:    / @greggowaffles  

Code:

Sub cap_words_in_string()

Dim word As Range
Dim ws As Worksheet
Dim row_count As Long
Dim col_count As Long

Set ws = ThisWorkbook.Sheets("Sheet2")

ws.Activate

row_count = ws.Cells(Rows.Count, 1).End(xlUp).Row
col_count = ws.Cells(1, Columns.Count).End(xlToLeft).Column

For Each word In Range(Cells(1, 1), Cells(row_count, col_count))

word.Value = StrConv(word.Value, vbProperCase)

Next word


End Sub

#excelmacro #excelvba