PDA

View Full Version : [SOLVED:] color uppercase words



Ethen5155
03-24-2018, 07:35 AM
Hi all,

i tried to do a macro that can color Camel Cases words like (UnderGround, FedEx) through all excel cells but i failed becasue i don't want to include text with space between the two words as shown below:

21907


Simply, i want to look for all words that have two upper cases characters without space between them and color it like (MyComputer or AppleIphone)


and to skip words like (My Computer or Apple Iphone) because there is a space between the two words






is it possible to do??

thanks in advance

Ethen



Cross-Posting: https://www.excelforum.com/excel-programming-vba-macros/1225319-color-uppercase-words.html#post4870363

Ethen5155
03-24-2018, 02:14 PM
Solved by: xladept (https://www.excelforum.com/members/304929.html)


Sub Ethen()
Dim r As Long, S As String, i As Long, c As Long
For r = 1 To Range("A" & Rows.Count).End(xlUp).Row
S = Range("A" & r): S = Left(Range("A" & r), InStr(1, S, " ") - 1)
For i = 1 To Len(S)
If Mid(S, i, 1) = UCase(Mid(S, i, 1)) Then c = c + 1
Next if
If c > 1 Then
Range("A" & r).Characters(Start:=1, Length:=Len(S)).Font.ColorIndex = 44
c = 0: End If
Next r
End Sub