Make last word proper

kpadventures90

New Member
Joined
Sep 12, 2024
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hey everyone,

I'm not very good at writing macros, but what I'm trying to do is make the last word in a string be proper, while leaving the rest of the string as it is. The report I have does everything fine, except the last word. Unfortunately I can't just make the whole string proper.

I'm working on a database that has many thousands of entries so it would be applied to a range, rather than just one cell.

I would rather do this with a macro than formulas as this will need to be done regularly and the report has data either side of column E (The one with the string that needs updating).

I've tried to follow what I can find online, but I either just get the last word replacing the entire string or a bunch of errors I don't know how to get around. Can someone who knows what they're doing please help?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Welcome to the MrExcel forum!

Try:

VBA Code:
Sub ProperEnd()
Dim Rng As Range, c As Variant, w as Variant

    Set Rng = Range("A1:A3")
   
    For Each c In Rng
        w = Split(c.Value, " ")
        w(UBound(w)) = WorksheetFunction.Proper(w(UBound(w)))
        c.Value = Join(w)
    Next c
   
End Sub

Change the range as needed.
 
Upvote 0
Welcome to the MrExcel forum!

Try:

VBA Code:
Sub ProperEnd()
Dim Rng As Range, c As Variant, w as Variant

    Set Rng = Range("A1:A3")
  
    For Each c In Rng
        w = Split(c.Value, " ")
        w(UBound(w)) = WorksheetFunction.Proper(w(UBound(w)))
        c.Value = Join(w)
    Next c
  
End Sub

Change the range as needed.
Sorry for the late reply, had life stuff pop up.

That works perfectly Eric, thank you so much!
 
Upvote 0

Forum statistics

Threads
1,223,950
Messages
6,175,582
Members
452,653
Latest member
craigje92

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