![]() |
Capitilize last word in cell
Hi,
I am trying to find a way to capitalize the last word in a cell. I frequently get names formatted where A1 = First Name A2 = Last name or A1=jan A2=van der hass and need to capitalize the h in hass. I have not been able to find a way to accomplish this. Your help is greatly appreciated. |
Capitilize last word in cell
Hi Mike,
Am Mon, 7 May 2012 17:29:06 +0000 schrieb MikeTi: I am trying to find a way to capitalize the last word in a cell. I frequently get names formatted where A1 = First Name A2 = Last name or A1=jan A2=van der hass and need to capitalize the h in hass. I have not been able to find a way to accomplish this. Your help is greatly appreciated. the simplest way is to do it with VBA. Formula: =LEFT(A2,FIND("#",SUBSTITUTE(A2," ","#",LEN(A2)-LEN(SUBSTITUTE(A2," ",)))))&PROPER(SUBSTITUTE(A2,LEFT(A2,FIND("#",SUBS TITUTE(A2," ","#",LEN(A2)-LEN(SUBSTITUTE(A2," ",))))),)) Macro: Sub Capitalize() Dim Start As Integer Dim LRow As Long Dim rngC As Range LRow = Cells(Rows.Count, 1).End(xlUp).Row For Each rngC In Range("A1:A" & LRow) Start = InStrRev(rngC, " ") rngC = Left(rngC, Start) & _ WorksheetFunction.Proper(Right(rngC, Len(rngC) - Start)) Next End Sub Regards Claus Busch -- Win XP PRof SP2 / Vista Ultimate SP2 Office 2003 SP2 /2007 Ultimate SP2 |
All times are GMT +1. The time now is 09:06 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com