Apply ProperCase to dynamic range in a column

Vincent88

Active Member
Joined
Mar 5, 2021
Messages
382
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
Hi, Appreciate any help to modify the code to apply the function to the dynamic range in a column only not whole column ?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim LastRow As Long
LastRow = Range("L2").End(xlDown).Row

If Target.Cells.Count > 1 Then Exit Sub
On Error GoTo ErrHandler:

If Target.Column = 12 Then
If Not IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target.Value = StrConv(Target.Text, vbProperCase)
Application.EnableEvents = True
End If
End If
ErrHandler:
Application.EnableEvents = True
End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Which cells do you want it to work on?
 
Upvote 0
But which cells if you don't want it on the whole column?
 
Upvote 0
Hi, the rows in dynamic range will grow, right ! So it should be the last row
 
Upvote 0
At the moment your code will work on any cell in col L, if that is not what you want, what cells in col L should it work on?
 
Upvote 0
Hi Fluff,
What I want if my table range is from L2 to L10, then the propercase function works within it ; if my range grows to L 21, then the function works from L2 to L21. That's why I create the LastRow Long but I do not know how modify it ?
 
Upvote 0
If your data is currently L2 to L10 & you enter something in L25 do you want that changed?
Also do you have any blanks cells in col L ?
 
Upvote 0
Hi Fluff,
To answer your quest : No function in L25, and I have blank cells outside the range in column L.
 
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,825
Members
449,190
Latest member
rscraig11

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