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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

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