Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default In a Shared Workbook of Excel, how do I change the color of a Cel.

In a Shared Workbook of Excel, how do I change the color of a Cell by simply
selecting it. For example, if I click on Cell B234 making it the Active
Cell, I want the color of Cell G234 to change to yellow.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default In a Shared Workbook of Excel, how do I change the color of a Cel.

Ahmed

Try putting this code on the sheet.
(Get into VBA and then Double-click on the sheet object)

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
ActiveCell.Interior.ColorIndex = 6
End Sub

Peter Bircher

"Ahmed" wrote in message
...
In a Shared Workbook of Excel, how do I change the color of a Cell by
simply
selecting it. For example, if I click on Cell B234 making it the Active
Cell, I want the color of Cell G234 to change to yellow.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default In a Shared Workbook of Excel, how do I change the color of a

Thank you, Pete, for responding. However, I get the following error message
when I attempt to run your code: "Unable to set the ColorIndex property of
the Interior Class.

I've been using the following code, but it does not work with a Shared
Workbook:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim iColor As Integer

'// Note: Don't use if you have conditional
'// formatting that you want to keep

'// On error resume in case user selects a range of cells
On Error Resume Next
iColor = Target.Interior.ColorIndex

'// Leave On Error ON for Row offset errors
If iColor < 0 Then
iColor = 36
Else
iColor = iColor + 1
End If

'// Need this test in case Font color is the same
If iColor = Target.Font.ColorIndex Then iColor = iColor + 1
Cells.FormatConditions.Delete

'// Horizontal color banding
With Range("Z" & Target.Row, Target.Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = iColor
End With


End Sub

"Pete" wrote:

Ahmed

Try putting this code on the sheet.
(Get into VBA and then Double-click on the sheet object)

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
ActiveCell.Interior.ColorIndex = 6
End Sub

Peter Bircher

"Ahmed" wrote in message
...
In a Shared Workbook of Excel, how do I change the color of a Cell by
simply
selecting it. For example, if I click on Cell B234 making it the Active
Cell, I want the color of Cell G234 to change to yellow.




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
can not change size of shared workbook John B Excel Discussion (Misc queries) 0 December 7th 09 08:13 PM
Format Change in Shared Workbook chunc Excel Worksheet Functions 0 July 29th 09 07:21 PM
Change protection of a shared workbook (Excel 2000) Farfel Excel Discussion (Misc queries) 0 December 18th 08 07:29 PM
Change scrollbar color in workbook in Excel XP ©LarryEº New Users to Excel 4 November 30th 08 12:35 PM
cant not change history on a shared workbook cyndi Excel Discussion (Misc queries) 0 December 15th 05 08:14 PM


All times are GMT +1. The time now is 08:11 AM.

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"