Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Propercase, strings and arrays

Hi,

I need to write some script that allows me to evaluate a cell values first 2
characters for "MC". If found Uppercase the 3rd Character. This way I can use
it and adapt it for any naming anomoly.

eg "MCCARTHY" - "McCarthy"

My thoughts were to put each character of the value and evaluate the first
character then the second. When a match is found re-write the value out of
the array in the correct casing format.


Cheers
--
Paul Wilson
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Propercase, strings and arrays


try this instead

if ucase(Range("A1")) = "MCCARTHY" then
Range("A1") = "McCarthy"
end if


for a more general case

if ucase(left(Range("A1"),3)) = "MCC" then
Range("A1") = "McC" & mid(Range("A1"),4)
end if


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=167693

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Propercase, strings and arrays

Hi Paul

Select the range to be converted and run the below macro which should
convert as specified. (script that allows me to evaluate a cell values first
2 characters for "MC")

Sub Macro()
Dim cell As Range
For Each cell In Selection
If UCase(cell.Text) Like "MC*" Then
cell.Value = "Mc" & StrConv(Mid(cell, 3), vbProperCase)
End If
Next
End Sub

--
Jacob


"Paul Wilson" wrote:

Hi,

I need to write some script that allows me to evaluate a cell values first 2
characters for "MC". If found Uppercase the 3rd Character. This way I can use
it and adapt it for any naming anomoly.

eg "MCCARTHY" - "McCarthy"

My thoughts were to put each character of the value and evaluate the first
character then the second. When a match is found re-write the value out of
the array in the correct casing format.


Cheers
--
Paul Wilson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Propercase, strings and arrays

See David McRitchie's site.

http://www.mvps.org/dmcritchie/excel/proper.htm


Gord Dibben MS Excel MVP

On Wed, 6 Jan 2010 19:39:02 -0800, Paul Wilson
wrote:

Hi,

I need to write some script that allows me to evaluate a cell values first 2
characters for "MC". If found Uppercase the 3rd Character. This way I can use
it and adapt it for any naming anomoly.

eg "MCCARTHY" - "McCarthy"

My thoughts were to put each character of the value and evaluate the first
character then the second. When a match is found re-write the value out of
the array in the correct casing format.


Cheers


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparison - Strings and Arrays jbtenor1 Excel Programming 3 April 13th 06 02:01 PM
How do I compare two arrays of numeric strings? john.jacobs71 Excel Programming 4 December 17th 05 04:59 PM
Help - Type mismatch when running loop with strings from arrays Marie J-son[_5_] Excel Programming 3 March 19th 05 08:36 PM
Arrays and Strings [email protected] Excel Programming 1 September 2nd 04 08:40 AM
Arrays and Strings [email protected] Excel Programming 2 September 2nd 04 02:53 AM


All times are GMT +1. The time now is 12:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"