Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default How to change color

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default How to change color

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...


-----Original Message-----
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



.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to change color

Look at the conditionnal format


Pat

"Eric" a écrit dans le message de
...
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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkbox to change background color, font color and remove/ add bo Sara Excel Discussion (Misc queries) 2 May 1st 23 11:43 AM
Change tab color based on current color of a cell MarkT Excel Discussion (Misc queries) 0 May 22nd 08 05:46 PM
how can I conditionally change font color, or background color? MOHA Excel Worksheet Functions 3 August 21st 06 06:57 PM
How to change the default Border, Font Color, and Cell Color Elijah Excel Discussion (Misc queries) 3 November 2nd 05 11:52 PM
Allow users to change the color of the comment indicator color so. DanC Excel Discussion (Misc queries) 1 February 25th 05 05:15 PM


All times are GMT +1. The time now is 10:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"