How to change color

E

Eric

Hello,

I have a problem writing a macro in my excel file, I want
to change the color of specific range and my data goes
like this:
Column1 Column2
Row 1: Filename ABC
Row 2: Desc ABC Company
..
..
..
Row 21: Filename DEF
Row 22: Desc DEF Enterprise
..
..
..
so on

I have to search for word "Filename" and if found, change
the "ABC" color to RED and go down change "ABC Company" to
Blue, and so on. Below is sample code, How could I do
this in loop (in Do While perhaps?) so that my code won't
be long.

Cells.Find(What:="Filename", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False).Activate
Range("B5").Select
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("B6").Select
Selection.Font.Bold = True
Selection.Font.ColorIndex = 10
Range("B7").Select
Selection.Font.Bold = True
Range("B8").Select
Selection.Font.Bold = True
Selection.Font.ColorIndex = 3
Cells.FindNext(After:=ActiveCell).Activate
Range("B75").Select
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("B76").Select
Selection.Font.Bold = True
Selection.Font.ColorIndex = 10
Range("B77").Select
Selection.Font.Bold = True
Range("B78").Select
Selection.Font.Bold = True
Selection.Font.ColorIndex = 3

Thanks everybody in advance for your help.
Eric
 
G

Guest

You can try using something like that

if Cells(RowIndex,Coulnm1)= "Filename" Then
Cells(RowIndex,Coulnm).interior.colorindex=3 And
Cells(RowIndex,Coulnm).interior.colorindex=5

And put it in the loop...
 

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

Top