vba capitalize 1st letter of each word then exit sub after correction

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,124
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I'm working with a sub trying to capitalize the first letter of each word in a column:

VBA Code:
Sub CapitalizeFirstWord1()
Dim rng As Range
For Each rng In Range("BA11:BA180")
rng.Value = StrConv(rng.Value, vbProperCase)
Next rng
Exit Sub
End Sub

However, when I apply this sub to its table column it takes to long to execute.

Do you know how I can add to this code, when it finds the lower-case word(s) in cell to then exit the sub in lieu of checking every cell in that column?

Please let me know.

Thank you very much!
pinaceous
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Give this a try.

VBA Code:
Sub CapitalizeFirstWord1_Mod()
    Dim rng As Range
    Dim arr As Variant
    
    Set rng = Range("BA11:BA180")
    arr = rng.Value
    arr = Application.Proper(arr)
    rng.Value = arr
End Sub
 
Upvote 0
Give this a try.

VBA Code:
Sub CapitalizeFirstWord1_Mod()
    Dim rng As Range
    Dim arr As Variant
   
    Set rng = Range("BA11:BA180")
    arr = rng.Value
    arr = Application.Proper(arr)
    rng.Value = arr
End Sub
Thank you Alex Blakenburg!
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top