Single Letter Coloring with VBA: how to color the vowels

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,786
Office Version
  1. 2016
Platform
  1. Windows
Anyone have any code for coloring a, e, i, o and u red when they appear in words on a sheet and color Y green/
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Code:
Sub ColorVowels()
Dim c As Range, d As Long
For Each c In ActiveSheet.UsedRange
    c.Font.Color = vbBlack
    For d = 1 To Len(c)
        Select Case LCase(Mid(c, d, 1))
        Case "a", "e", "i", "o", "u"
            c.Characters(d, 1).Font.Color = vbRed
        Case "y"
            c.Characters(d, 1).Font.Color = vbGreen
        End Select
    Next
Next
End Sub
 
Upvote 0
I added this to each Case to bold the letters:

c.Characters(d, 1).Font.Bold = True

Is there a better way to do this?
 
Upvote 0
Alrighty then, thanks again, this works great.
 
Upvote 0

Forum statistics

Threads
1,222,095
Messages
6,163,901
Members
451,865
Latest member
dunworthc

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top