![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Join Date: Nov 2002
Posts: 19
|
Hi All,
I use the PROPER function to turn uppercase to sentence case when composing a mailing list. Is there any way to capitalise the letter after the Mc or Mac at the start of certain surnames, without searching for 'Mc' and manually amending it? Thanks |
|
|
|
|
|
#2 |
|
Join Date: Jan 2003
Location: Round Rock, Texas
Posts: 564
|
A related post that unfortunately doesn't really answer your question, except to point out the problem(s) with your request:
http://www.mrexcel.com/board2/viewtopic.php?t=70919 Maybe al_b_cnu's fuzzy lookup UDF can help, though? BOL, Tom |
|
|
|
|
|
#3 |
|
MrExcel MVP
Moderator Join Date: Aug 2002
Posts: 14,220
|
You could write a macro to do the Search and Replace for you, but as the thread rrdonutz referenced suggests, there may be too many possibilites and exceptions to program something reliable.
__________________
TIPS FOR FINDING EXCEL SOLUTIONS 1. Use the built-in Help that comes with Excel/Access 2. Use the Search functionality on this board 3. A lot of VBA code can be acquired by using the Macro Recorder. |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: California
Posts: 3,857
|
Try this:
=IF(LEFT(A1,2)="mc","Mc"&UPPER(MID(A1,3,1))&LOWER(MID(A1,4,LEN(A1))),IF(LEFT(A1,3)="mac","Mac"&UPPER(MID(A1,4,1))&LOWER(MID(A1,5,LEN(A1))),A1)) |
|
|
|
|
|
#5 |
|
Join Date: Jan 2003
Location: Round Rock, Texas
Posts: 564
|
Hi DRJ,
Your formula works, but . . . try it with names like: Mack Macklin Mackovic I doubt these folks want their names to become: MacK MacKlin MacKovic These are just a few of the exceptions that need a "work-around". |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: California
Posts: 3,857
|
Thats true. I suppose you could look at the letter after the mac or mc and if it is a D then capitalize it, or other letters that are likely to need to be capitals, but it is not 100%.
Of course the OP just wanted to cap the letter after mac or mc so that's all I tried to do. |
|
|
|
|
|
#7 |
|
Join Date: Aug 2002
Location: Virginia
Posts: 126
|
will you be using the same names every time?
If no new names are expected, then just program a macro around the names you have.. |
|
|
|
|
|
#8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Join Date: Jul 2002
Location: Perth, Australia
Posts: 1,416
|
Joey,
One way: Setup a matrix in the worksheet named “Setup": ******** ******************** ************************************************************************>
[HtmlMaker 2.42] To see the formula in the cells just click on the cells hyperlink or click the Name box PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR. The green cells are named “MyRng” – make it a dynamic range so that it auto corrects for additions/deletions. Put the following macro in a normal module and assign it to a button from the Forms menu. The macro works on the Activesheet. Code:
Option Explicit
Sub replaceWord()
Dim myReplace As Variant
Dim i As Integer
With ThisWorkbook.Worksheets("Setup")
myReplace = .Range("MyRng").Value
End With
For i = 1 To UBound(myReplace)
If Not IsEmpty(myReplace(i, 1)) Then
ActiveSheet.Cells.Replace What:=myReplace(i, 1), _
Replacement:=myReplace(i, 2)
End If
Next i
End Sub
HTH Mike |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|