Propercase - macro so that it will change all names in a column to Proper case

nazaroff

New Member
Joined
Nov 2, 2023
Messages
3
Office Version
  1. 2010
Platform
  1. Windows
Can someone tell me or correct this - I want to execute this macro so that it will change all names in a column to Proper case - this formula gives me an error??

Sub ProperSelection()
For Each cell In Selection IF Not cell.HasFormula Then cell.Value=Application.WorksheetFunction.Proper(Cell.Value) End If Next cell
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Does your code look like the below in reality?
VBA Code:
Sub ProperSelection()
For Each cell In Selection
  If Not cell.HasFormula Then
    cell.Value = Application.WorksheetFunction.Proper(Cell.Value)
  End If
Next cell
End Sub
 
Upvote 0
Code:
Sub ProperSelection()
Dim cell As Range

For Each cell In Selection
   If Not cell.HasFormula Then cell.Value = Application.WorksheetFunction.Proper(cell.Value)
Next cell
End Sub
 
Upvote 0
Solution
Does your code look like the below in reality?
VBA Code:
Sub ProperSelection()
For Each cell In Selection
  If Not cell.HasFormula Then
    cell.Value = Application.WorksheetFunction.Proper(Cell.Value)
  End If
Next cell
End Sub
Thanks for your response! - I got it :)
 
Upvote 0
Happy we helped

As you can see by the post by @ranman256 if you are only doing a single action then you can do away with the separate End If and lose 2 lines, just note that you can only do this with one action not multiple actions (bar using some ugly colons to replace the linefeeds)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,103
Members
452,379
Latest member
IainTru

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