Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change Cell Color
I am currently using the following code to change the cell color, I have five
sheets in the workbook (they all have the same color with this code), What would be the code to be able to set each sheet to have its own color? Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range) Static OldCell As Range If Not OldCell Is Nothing Then OldCell.Interior.ColorIndex = xlColorIndexNone End If Target.Interior.ColorIndex = 6 Set OldCell = Target End Sub Thanks, Bob |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change Cell Color
Option Base 1
Private Sub Workbook_SheetSelectionChange( _ ByVal Sh As Object, _ ByVal Target As Excel.Range) Static OldCell As Range If Not OldCell Is Nothing Then OldCell.Interior.ColorIndex = xlColorIndexNone End If Target.Interior.ColorIndex = Array(8, 7, 6, 5, 4, 3, 2, 1)(Sh.Index) Set OldCell = Target End Sub HTH -- AP "Bob" a écrit dans le message de news: ... I am currently using the following code to change the cell color, I have five sheets in the workbook (they all have the same color with this code), What would be the code to be able to set each sheet to have its own color? Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range) Static OldCell As Range If Not OldCell Is Nothing Then OldCell.Interior.ColorIndex = xlColorIndexNone End If Target.Interior.ColorIndex = 6 Set OldCell = Target End Sub Thanks, Bob |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change Cell Color
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Excel.Range) Static OldCell As Range If Not OldCell Is Nothing Then OldCell.Interior.ColorIndex = xlColorIndexNone End If Select Case sh.Name Case "Sheet1" Target.Interior.ColorIndex = 6 Case "Sheet2" Target.Interior.ColorIndex = 10 Case "Sheet3" Target.Interior.ColorIndex = 4 Case "Sheet4" Target.Interior.ColorIndex = 7 Case "Sheet5" Target.interior.ColorIndex = 12 Case Else End Select Set OldCell = Target End Sub -- Regards, Tom Ogilvy "Bob" wrote: I am currently using the following code to change the cell color, I have five sheets in the workbook (they all have the same color with this code), What would be the code to be able to set each sheet to have its own color? Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range) Static OldCell As Range If Not OldCell Is Nothing Then OldCell.Interior.ColorIndex = xlColorIndexNone End If Target.Interior.ColorIndex = 6 Set OldCell = Target End Sub Thanks, Bob |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change Cell Color
Work Great,
Thanks "Tom Ogilvy" wrote: Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range) Static OldCell As Range If Not OldCell Is Nothing Then OldCell.Interior.ColorIndex = xlColorIndexNone End If Select Case sh.Name Case "Sheet1" Target.Interior.ColorIndex = 6 Case "Sheet2" Target.Interior.ColorIndex = 10 Case "Sheet3" Target.Interior.ColorIndex = 4 Case "Sheet4" Target.Interior.ColorIndex = 7 Case "Sheet5" Target.interior.ColorIndex = 12 Case Else End Select Set OldCell = Target End Sub -- Regards, Tom Ogilvy "Bob" wrote: I am currently using the following code to change the cell color, I have five sheets in the workbook (they all have the same color with this code), What would be the code to be able to set each sheet to have its own color? Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range) Static OldCell As Range If Not OldCell Is Nothing Then OldCell.Interior.ColorIndex = xlColorIndexNone End If Target.Interior.ColorIndex = 6 Set OldCell = Target End Sub Thanks, Bob |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change tab color based on current color of a cell | Excel Discussion (Misc queries) | |||
Excel: Syntax to change cell color based on color of another cell | Excel Worksheet Functions | |||
change fill color of a range of cells based on color of a cell? | Excel Programming | |||
How to change the default Border, Font Color, and Cell Color | Excel Discussion (Misc queries) | |||
Browse Forms Controls and change TextBox color based on cell color | Excel Programming |