Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default 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
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
Change tab color based on current color of a cell MarkT Excel Discussion (Misc queries) 0 May 22nd 08 05:46 PM
Excel: Syntax to change cell color based on color of another cell davew18 Excel Worksheet Functions 1 January 4th 07 01:24 PM
change fill color of a range of cells based on color of a cell? DarMelNel Excel Programming 0 March 2nd 06 06:35 PM
How to change the default Border, Font Color, and Cell Color Elijah Excel Discussion (Misc queries) 3 November 2nd 05 11:52 PM
Browse Forms Controls and change TextBox color based on cell color StefanW Excel Programming 2 November 21st 04 07:06 PM


All times are GMT +1. The time now is 04:51 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"