Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Checkbox to change background color, font color and remove/ add bo | Excel Discussion (Misc queries) | |||
Change tab color based on current color of a cell | Excel Discussion (Misc queries) | |||
how can I conditionally change font color, or background color? | Excel Worksheet Functions | |||
How to change the default Border, Font Color, and Cell Color | Excel Discussion (Misc queries) | |||
Allow users to change the color of the comment indicator color so. | Excel Discussion (Misc queries) |