Column that needs separation

A

Aaron

I am very new with excel and I am putting together a worksheet that has a
column consisting of two primary names. I would like to format the entire
column with the result being both names having their own color throughout the
column. Alternatively, I could go to each row and highlight the name but
there are about 1000 rows.

Thanks,
Aaron
 
G

Gary''s Student

Say column A has entries like:

James Ravenswood

Run this small macro:

Sub Colorizer()
Dim A As Range, r As Range
Set A = Intersect(ActiveSheet.UsedRange, Range("A:A"))
For Each r In A
v = r.Value
s = Split(v, " ")
L1 = Len(s(0))
L2 = Len(s(1))
S1 = 1
S2 = L1 + 2
r.Characters(Start:=S1, Length:=L1).Font.ColorIndex = 3
r.Characters(Start:=S2, Length:=L2).Font.ColorIndex = 6
Next
End Sub

will result in James colored red and Ravenswood colored yellow.


Macros are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To use the macro from Excel:

1. ALT-F8
2. Select the macro
3. Touch RUN

To learn more about macros in general, see:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top