MetaChat REGISTER   ||   LOGIN   ||   IMAGES ARE OFF   ||   RECENT COMMENTS




artphoto by splunge
artphoto by TheophileEscargot
artphoto by Kronos_to_Earth
artphoto by ethylene

Home

About

Search

Archives

Mecha Wiki

Metachat Eye

Emcee

IRC Channels

IRC FAQ


 RSS


Comment Feed:

RSS

02 November 2007

Help me automate my task, O Excel/Office wizards! [More:]I have some strings of text in an Excel spreadsheet. Some are in ALL CAPS, some have just a Capital letter at the beginning of a string, and some have a Capital Letter At The Beginning Of Each Word, Even The Small Ones.

I want to fix the strings of the third type so they are like the second type, i.e. with only the initial capital still in place. Any way I can do this while a) leaving the ALL CAPS and initial caps in place and b) not going through and correcting them individually? I'm thinking there must be a way involving wildcards and find/replace, but my brain is broken.

And yes, I have no way of getting out of this task.
The answer has to be here somewhere.
posted by chuckdarwin 02 November | 07:04
From Here
Sub SentenceCase()
For Each cell In Selection.Cells
s = cell.Value
Start = True
For i = 1 To Len(s)
ch = Mid(s, i, 1)
Select Case ch
Case "."
Start = True
Case "?"
Start = True
Case "a" To "z"
If Start Then ch = UCase(ch): Start = False
Case "A" To "Z"
If Start Then Start = False Else ch = LCase(ch)
End Select
Mid(s, i, 1) = ch
Next
cell.Value = s
Next
End Sub
posted by seanyboy 02 November | 07:17
omg, admin/books gold, both of you, those sites.
posted by By the Grace of God 02 November | 07:19
Wow. thank you so much! If I'd twigged that 'sentence case' was the crucial descriptor here, I might have got further by myself. But thanks a million.

/has also never been to a meetup and is grateful for the help and enlightenment available here.
posted by altolinguistic 02 November | 07:27
nice one, seanyboy! i was going to suggest a nested IF formula that used UPPER(), LOWER() and PROPER() to avoid having to mess around w/VBA...
posted by syntax 02 November | 07:34
^eponysterical
posted by altolinguistic 02 November | 07:43
TMTOWTDI: if I'm reading you right, you want anything in all caps to stay the same, and anything else to have its first letter capped.

=IF(EXACT(UPPER(A1), A1), A1, UPPER(LEFT(A1,1)) & LOWER(RIGHT(A1, LEN(A1)-1)))

This assumes one string per cell.
posted by eamondaly 02 November | 17:11
Brotherly || But wait ... there's more!

HOME  ||   REGISTER  ||   LOGIN